[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master efa79f5c 07/13: Establish unit tests for CRTP
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master efa79f5c 07/13: Establish unit tests for CRTP convenience classes |
Date: |
Wed, 27 Jul 2022 15:16:33 -0400 (EDT) |
branch: master
commit efa79f5cf181bebebd935e991cef8fa9e671e577
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Establish unit tests for CRTP convenience classes
The unit test consists solely of moved comments for now.
---
Makefile.am | 8 ++++++++
crtp_base.hpp | 15 ---------------
crtp_base_test.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
objects.make | 5 +++++
4 files changed, 62 insertions(+), 15 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index e476a9a3..4c006c25 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -112,6 +112,7 @@ TESTS = \
configurable_settings_test \
contains_test \
crc32_test \
+ crtp_base_test \
currency_test \
dbo_rules_test \
duff_fmt_test \
@@ -692,6 +693,12 @@ crc32_test_CXXFLAGS = $(AM_CXXFLAGS)
crc32_test_LDADD = \
libtest_common.la
+crtp_base_test_SOURCES = \
+ crtp_base_test.cpp
+crtp_base_test_CXXFLAGS = $(AM_CXXFLAGS)
+crtp_base_test_LDADD = \
+ libtest_common.la
+
currency_test_LDADD = \
libtest_common.la
@@ -1166,6 +1173,7 @@ noinst_HEADERS = \
configurable_settings.hpp \
contains.hpp \
crc32.hpp \
+ crtp_base.hpp \
cso_table.hpp \
currency.hpp \
custom_io_0.hpp \
diff --git a/crtp_base.hpp b/crtp_base.hpp
index 2d8cdb09..53890cef 100644
--- a/crtp_base.hpp
+++ b/crtp_base.hpp
@@ -121,19 +121,4 @@ class uncopyable
} // namespace lmi
-// If lmi provided unit tests that deliberately fail to compile, then
-// this could be used:
-//
-// #include "uncopyable_lmi.hpp"
-//
-// class X : private lmi::uncopyable<X> {};
-//
-// int main()
-// {
-// X x;
-// X y(x); // Error: cannot copy.
-// x = y; // Error: cannot assign.
-// }
-
#endif // crtp_base_hpp
-
diff --git a/crtp_base_test.cpp b/crtp_base_test.cpp
new file mode 100644
index 00000000..004cc54f
--- /dev/null
+++ b/crtp_base_test.cpp
@@ -0,0 +1,49 @@
+// Convenient base classes that use CRTP--unit test.
+//
+// Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2022 Gregory
W. Chicares.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// 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, write to the Free Software Foundation,
+// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+//
+// https://savannah.nongnu.org/projects/lmi
+// email: <gchicares@sbcglobal.net>
+// snail: Chicares, 186 Belle Woods Drive, Glastonbury CT 06033, USA
+
+#include "pchfile.hpp"
+
+#include "crtp_base.hpp"
+
+#include "test_tools.hpp"
+
+void test_uncopyable()
+{
+// If lmi provided unit tests that deliberately fail to compile, then
+// this could be used:
+//
+// #include "uncopyable_lmi.hpp"
+//
+// class X : private lmi::uncopyable<X> {};
+//
+// int main()
+// {
+// X x;
+// X y(x); // Error: cannot copy.
+// x = y; // Error: cannot assign.
+// }
+}
+
+int test_main(int, char*[])
+{
+ test_uncopyable();
+ return 0;
+}
diff --git a/objects.make b/objects.make
index c3f3e637..fe98addf 100644
--- a/objects.make
+++ b/objects.make
@@ -385,6 +385,7 @@ unit_test_targets := \
configurable_settings_test \
contains_test \
crc32_test \
+ crtp_base_test \
currency_test \
dbo_rules_test \
duff_fmt_test \
@@ -583,6 +584,10 @@ crc32_test$(EXEEXT): \
crc32.o \
crc32_test.o \
+crtp_base_test$(EXEEXT): \
+ $(common_test_objects) \
+ crtp_base_test.o \
+
currency_test$(EXEEXT): \
$(common_test_objects) \
currency_test.o \
- [lmi-commits] [lmi] master updated (6126d1e0 -> a07a61b8), Greg Chicares, 2022/07/27
- [lmi-commits] [lmi] master 7649cf4d 05/13: Modernize class uncopyable and its documentation, Greg Chicares, 2022/07/27
- [lmi-commits] [lmi] master 41339667 06/13: Rename uncopyable_lmi.hpp -> crtp_base.hpp, Greg Chicares, 2022/07/27
- [lmi-commits] [lmi] master 48007e3c 09/13: Support an abstract-xor-final hierarchy, Greg Chicares, 2022/07/27
- [lmi-commits] [lmi] master a07a61b8 13/13: Declutter, Greg Chicares, 2022/07/27
- [lmi-commits] [lmi] master 22a759fa 12/13: Devirtualize, Greg Chicares, 2022/07/27
- [lmi-commits] [lmi] master f12819ba 02/13: Make md5sum_for_file ctor noexcept, Greg Chicares, 2022/07/27
- [lmi-commits] [lmi] master 6e590f5c 01/13: Work around a spurious gcc 12 -Wnull-dereference, Greg Chicares, 2022/07/27
- [lmi-commits] [lmi] master 0c2fceb0 04/13: Resurrect 'uncopyable_lmi.hpp', Greg Chicares, 2022/07/27
- [lmi-commits] [lmi] master cde94ff9 10/13: Use an abstract-xor-final hierarchy, Greg Chicares, 2022/07/27
- [lmi-commits] [lmi] master efa79f5c 07/13: Establish unit tests for CRTP convenience classes,
Greg Chicares <=
- [lmi-commits] [lmi] master 4ebf92ed 03/13: Suppress warnings for deprecated unary_function in cgicc, Greg Chicares, 2022/07/27
- [lmi-commits] [lmi] master 21685250 11/13: Use another abstract-xor-final hierarchy, Greg Chicares, 2022/07/27
- [lmi-commits] [lmi] master 2143f359 08/13: Add unit tests for CRTP convenience classes, Greg Chicares, 2022/07/27