From: Bruno Haible Date: Sat, 31 May 2025 21:43:24 +0000 (+0200) Subject: stat-time tests: Add C++ tests. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c384a44fc201e0ae6d23138727ad9080fc314fe9;p=thirdparty%2Fgnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index 1ffa32c753..e9b9bd011f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2025-05-31 Bruno Haible + 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): diff --git a/modules/stat-time-c++-tests b/modules/stat-time-c++-tests new file mode 100644 index 0000000000..e4dfb485c6 --- /dev/null +++ b/modules/stat-time-c++-tests @@ -0,0 +1,19 @@ +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 diff --git a/modules/stat-time-tests b/modules/stat-time-tests index c1f962c243..367a1f6ba9 100644 --- a/modules/stat-time-tests +++ b/modules/stat-time-tests @@ -10,6 +10,7 @@ time-h unistd-h xconcat-filename xgetcwd-lgpl +stat-time-c++-tests configure.ac: diff --git a/tests/test-stat-time-c++.cc b/tests/test-stat-time-c++.cc new file mode 100644 index 0000000000..2f2488d89b --- /dev/null +++ b/tests/test-stat-time-c++.cc @@ -0,0 +1,33 @@ +/* Test of 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 . */ + +#define GNULIB_NAMESPACE gnulib +#include + +#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); +}