lmi-commits
[Top][All Lists]
Advanced

[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*[])



reply via email to

[Prev in Thread] Current Thread [Next in Thread]