From: Bruno Haible Date: Sat, 10 Sep 2022 18:01:24 +0000 (+0200) Subject: Reorganize C++ tests for stdbool and stdbool-c99. X-Git-Tag: v1.0~2040 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=8b21d104b20dfcbb5ddb8ca69fa64776487ceec6;p=gnulib.git Reorganize C++ tests for stdbool and stdbool-c99. * tests/test-stdbool-c++.cc: Don't include if TEST_STDBOOL_H is not defined. Add a couple of simple tests, from test-stdbool.c. * tests/test-stdbool-c99-c++.cc: New file. * modules/stdbool-c99-c++-tests: New file, based on modules/stdbool-c++-tests. * modules/stdbool-c99-tests (Depends-on): Add stdbool-c99-c++-tests. Remove stdbool-c++-tests. * modules/stdbool-tests (Depends-on): Add stdbool-c++-tests. --- diff --git a/ChangeLog b/ChangeLog index 055523eff9..bdec7ddfa2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2022-09-10 Bruno Haible + + Reorganize C++ tests for stdbool and stdbool-c99. + * tests/test-stdbool-c++.cc: Don't include if TEST_STDBOOL_H + is not defined. Add a couple of simple tests, from test-stdbool.c. + * tests/test-stdbool-c99-c++.cc: New file. + * modules/stdbool-c99-c++-tests: New file, based on + modules/stdbool-c++-tests. + * modules/stdbool-c99-tests (Depends-on): Add stdbool-c99-c++-tests. + Remove stdbool-c++-tests. + * modules/stdbool-tests (Depends-on): Add stdbool-c++-tests. + 2022-09-10 Bruno Haible stdbool C++ tests: Fix for C++20. diff --git a/modules/stdbool-c99-c++-tests b/modules/stdbool-c99-c++-tests new file mode 100644 index 0000000000..073ef893c4 --- /dev/null +++ b/modules/stdbool-c99-c++-tests @@ -0,0 +1,19 @@ +Files: +tests/test-stdbool-c99-c++.cc +tests/test-stdbool-c++.cc +tests/test-stdbool-c++2.cc + +Status: +c++-test + +Depends-on: +ansi-c++-opt + +configure.ac: + +Makefile.am: +if ANSICXX +TESTS += test-stdbool-c99-c++ +check_PROGRAMS += test-stdbool-c99-c++ +test_stdbool_c99_c___SOURCES = test-stdbool-c99-c++.cc test-stdbool-c++2.cc +endif diff --git a/modules/stdbool-c99-tests b/modules/stdbool-c99-tests index 3ca0ddb217..e507f9493a 100644 --- a/modules/stdbool-c99-tests +++ b/modules/stdbool-c99-tests @@ -1,9 +1,9 @@ Files: -tests/test-stdbool.c tests/test-stdbool-c99.c +tests/test-stdbool.c Depends-on: -stdbool-c++-tests +stdbool-c99-c++-tests configure.ac: diff --git a/modules/stdbool-tests b/modules/stdbool-tests index 6905dfbedc..0f875fbeed 100644 --- a/modules/stdbool-tests +++ b/modules/stdbool-tests @@ -2,6 +2,7 @@ Files: tests/test-stdbool.c Depends-on: +stdbool-c++-tests configure.ac: diff --git a/tests/test-stdbool-c++.cc b/tests/test-stdbool-c++.cc index ae4f80b00f..8e208dfe23 100644 --- a/tests/test-stdbool-c++.cc +++ b/tests/test-stdbool-c++.cc @@ -19,7 +19,26 @@ #define GNULIB_NAMESPACE gnulib #include -#include +#ifdef TEST_STDBOOL_H +# include +#endif + + +/* These tests are a subset of the C language tests in test-stdbool.c. */ + +#if false + "error: false is not 0" +#endif +#if true != 1 + "error: true is not 1" +#endif + +struct s { bool s: 1; bool t; } s; + +char a[true == 1 ? 1 : -1]; +char b[false == 0 ? 1 : -1]; +char c[(unsigned char) true == 1 ? 1 : -1]; +char d[(unsigned char) false == 0 ? 1 : -1]; int diff --git a/tests/test-stdbool-c99-c++.cc b/tests/test-stdbool-c99-c++.cc new file mode 100644 index 0000000000..eec9e3b980 --- /dev/null +++ b/tests/test-stdbool-c99-c++.cc @@ -0,0 +1,2 @@ +#define TEST_STDBOOL_H +#include "test-stdbool-c++.cc"