]> Savannah Git Hosting - gnulib.git/commitdiff
endian tests: Verify that it can be used from C++.
authorBruno Haible <bruno@clisp.org>
Sat, 18 May 2024 10:31:15 +0000 (12:31 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 18 May 2024 10:31:15 +0000 (12:31 +0200)
* tests/test-endian-c++.cc: New file.
* modules/endian-c++-tests: New file.
* modules/endian-tests (Depends-on): Add endian-c++-tests.

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

index 322aaf362d5e6d699b782eaaf43b4a6fe558e2c2..29adf56ab7204366db4a2cc62ff8dff6d849bb61 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-05-18  Bruno Haible  <bruno@clisp.org>
+
+       endian tests: Verify that it can be used from C++.
+       * tests/test-endian-c++.cc: New file.
+       * modules/endian-c++-tests: New file.
+       * modules/endian-tests (Depends-on): Add endian-c++-tests.
+
 2024-05-18  Bruno Haible  <bruno@clisp.org>
 
        endian: Update doc and strengthen tests.
diff --git a/modules/endian-c++-tests b/modules/endian-c++-tests
new file mode 100644 (file)
index 0000000..d358ac1
--- /dev/null
@@ -0,0 +1,17 @@
+Files:
+tests/test-endian-c++.cc
+
+Status:
+c++-test
+
+Depends-on:
+ansi-c++-opt
+
+configure.ac:
+
+Makefile.am:
+if ANSICXX
+TESTS += test-endian-c++
+check_PROGRAMS += test-endian-c++
+test_endian_c___SOURCES = test-endian-c++.cc
+endif
index 8ec67a1c42e743a82e93d9b64a8a8948b6958f5d..e5d6da19b62c64e381616306ca7da542a70100ad 100644 (file)
@@ -5,6 +5,7 @@ tests/macros.h
 Depends-on:
 assert-h
 stdint
+endian-c++-tests
 
 configure.ac:
 
diff --git a/tests/test-endian-c++.cc b/tests/test-endian-c++.cc
new file mode 100644 (file)
index 0000000..25c1ab0
--- /dev/null
@@ -0,0 +1,32 @@
+/* Test of <endian.h> substitute in C++ mode.
+   Copyright (C) 2024 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/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2024.  */
+
+#define GNULIB_NAMESPACE gnulib
+#include <config.h>
+
+#include <endian.h>
+
+/* Check against conflicts between <endian.h> and the C++ header files.  */
+#include <stddef.h>
+#include <iostream>
+
+
+int
+main ()
+{
+}