2025-05-31 Bruno Haible <bruno@clisp.org>
+ stat-time tests: Add C++ tests.
+ * tests/test-stat-time-c++.cc: New file.
+ * modules/stat-time-c++-tests: New file.
+ * modules/stat-time-tests (Depends-on): Add stat-time-c++-tests.
+
stat-time: Fix syntax errors in C++ mode on MSVC (regr. 2023-05-14).
* lib/stat-time.h (_gl_make_timespec): New macro / function.
(get_stat_atime, get_stat_ctime, get_stat_mtime, get_stat_birthtime):
--- /dev/null
+Files:
+tests/test-stat-time-c++.cc
+tests/signature.h
+
+Status:
+c++-test
+
+Depends-on:
+ansi-c++-opt
+
+configure.ac:
+
+Makefile.am:
+if ANSICXX
+TESTS += test-stat-time-c++
+check_PROGRAMS += test-stat-time-c++
+test_stat_time_c___SOURCES = test-stat-time-c++.cc
+test_stat_time_c___LDADD = $(LDADD) $(LIBINTL) $(NANOSLEEP_LIB) $(CLOCK_TIME_LIB) $(MBRTOWC_LIB) $(GETRANDOM_LIB)
+endif
--- /dev/null
+/* Test of <stat-time.h> in C++ mode.
+ Copyright (C) 2025 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#define GNULIB_NAMESPACE gnulib
+#include <config.h>
+
+#include "stat-time.h"
+
+struct stat statinfo;
+
+int
+main (void)
+{
+ struct timespec a, c, m, b;
+ a = get_stat_atime (&statinfo);
+ c = get_stat_ctime (&statinfo);
+ m = get_stat_mtime (&statinfo);
+ b = get_stat_birthtime (&statinfo);
+ (void) (a.tv_sec + c.tv_sec + m.tv_sec + b.tv_sec);
+}