[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 2143f359 08/13: Add unit tests for CRTP conve
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 2143f359 08/13: Add unit tests for CRTP convenience classes |
Date: |
Wed, 27 Jul 2022 15:16:33 -0400 (EDT) |
branch: master
commit 2143f359d361002e9c4d2f573512b9555b0785f9
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Add unit tests for CRTP convenience classes
---
crtp_base_test.cpp | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/crtp_base_test.cpp b/crtp_base_test.cpp
index 004cc54f..85922081 100644
--- a/crtp_base_test.cpp
+++ b/crtp_base_test.cpp
@@ -25,21 +25,23 @@
#include "test_tools.hpp"
+#include <type_traits>
+
+class X : private lmi::uncopyable<X> {};
+
+/// Test uncopyability (and unmovability) of lmi::uncopyable derivatives.
+///
+/// Unlike most lmi unit tests, the conditions tested are all
+/// ascertainable at compile time.
+
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.
-// }
+ static_assert( std::is_default_constructible_v <X>);
+ static_assert( std::is_destructible_v <X>);
+ static_assert(!std::is_copy_constructible_v <X>);
+ static_assert(!std::is_move_constructible_v <X>);
+ static_assert(!std::is_copy_assignable_v <X>);
+ static_assert(!std::is_move_assignable_v <X>);
}
int test_main(int, char*[])
- [lmi-commits] [lmi] master 48007e3c 09/13: Support an abstract-xor-final hierarchy, (continued)
- [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, 2022/07/27
- [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 <=