]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
stat-time tests: Add C++ tests.
authorBruno Haible <bruno@clisp.org>
Sat, 31 May 2025 21:43:24 +0000 (23:43 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 31 May 2025 23:10:43 +0000 (01:10 +0200)
* 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.

ChangeLog
modules/stat-time-c++-tests [new file with mode: 0644]
modules/stat-time-tests
tests/test-stat-time-c++.cc [new file with mode: 0644]

index 1ffa32c7533baecfa932aaa0b7e804af142a15f1..e9b9bd011f92c9909cdf63dba9a556c383a22e73 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 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):
diff --git a/modules/stat-time-c++-tests b/modules/stat-time-c++-tests
new file mode 100644 (file)
index 0000000..e4dfb48
--- /dev/null
@@ -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
index c1f962c243bb734e4e8f67f8fd7a9fce45f81640..367a1f6ba9fb48f1c2aef44edb9e168edb173f6c 100644 (file)
@@ -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 (file)
index 0000000..2f2488d
--- /dev/null
@@ -0,0 +1,33 @@
+/* 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);
+}