diff --git a/src/tools/std20/concepts/test/CMakeLists.txt b/src/tools/std20/concepts/test/CMakeLists.txt index 60a6341..1e459fc 100644 --- a/src/tools/std20/concepts/test/CMakeLists.txt +++ b/src/tools/std20/concepts/test/CMakeLists.txt @@ -7,6 +7,22 @@ add_cpp_test( std20.concepts.integral integral.test.cpp ) add_cpp_test( std20.concepts.signed_integral signed_integral.test.cpp ) add_cpp_test( std20.concepts.unsigned_integral unsigned_integral.test.cpp ) add_cpp_test( std20.concepts.floating_point floating_point.test.cpp ) - +#add_cpp_test( std20.concepts.assignable_from assignable_from.test.cpp ) +#add_cpp_test( std20.concepts.swappable swappable.test.cpp ) +add_cpp_test( std20.concepts.destructible destructible.test.cpp ) +add_cpp_test( std20.concepts.constructible_from constructible_from.test.cpp ) +add_cpp_test( std20.concepts.default_initializable default_initializable.test.cpp ) +#add_cpp_test( std20.concepts.move_constructible move_constructible.test.cpp ) +#add_cpp_test( std20.concepts.copy_constructible copy_constructible.test.cpp ) add_cpp_test( std20.concepts.equality_comparable equality_comparable.test.cpp ) add_cpp_test( std20.concepts.totally_ordered totally_ordered.test.cpp ) +#add_cpp_test( std20.concepts.movable movable.test.cpp ) +#add_cpp_test( std20.concepts.copyable copyable.test.cpp ) +#add_cpp_test( std20.concepts.semiregular semiregular.test.cpp ) +#add_cpp_test( std20.concepts.regular regular.test.cpp ) +#add_cpp_test( std20.concepts.invocable invocable.test.cpp ) +#add_cpp_test( std20.concepts.regular_invocable regular_invocable.test.cpp ) +#add_cpp_test( std20.concepts.predicate predicate.test.cpp ) +#add_cpp_test( std20.concepts.relation relation.test.cpp ) +#add_cpp_test( std20.concepts.equivalence_relation equivalence_relation.test.cpp ) +#add_cpp_test( std20.concepts.strict_weak_order strict_weak_order.test.cpp ) diff --git a/src/tools/std20/concepts/test/constructible_from.test.cpp b/src/tools/std20/concepts/test/constructible_from.test.cpp new file mode 100644 index 0000000..f4a6e59 --- /dev/null +++ b/src/tools/std20/concepts/test/constructible_from.test.cpp @@ -0,0 +1,93 @@ +// include Catch2 +#include + +// what we are testing +#include "tools/std20/concepts.hpp" + +// other includes +#include + +// convenience typedefs +//using namespace njoy::tools; +namespace std20 = nano::ranges; + +// test code +struct Foo { + + ~Foo() noexcept {}; +}; + +struct NonDefaultConstructableFoo { + + NonDefaultConstructableFoo() = delete; + ~NonDefaultConstructableFoo() noexcept {}; +}; + +struct Bar { + + Bar() = default; + explicit Bar( int ); + ~Bar() = default; +}; + +SCENARIO( "constructible_from" ) { + + CHECK( std20::constructible_from< Foo > ); + CHECK( std20::constructible_from< Bar > ); + CHECK( std20::constructible_from< std::string > ); + CHECK( std20::constructible_from< Bar, int > ); + + CHECK( ! std20::constructible_from< NonDefaultConstructableFoo > ); + + CHECK( std20::constructible_from< int > ); + CHECK( std20::constructible_from< const int > ); + CHECK( ! std20::constructible_from< const int& > ); + CHECK( ! std20::constructible_from< int() > ); + CHECK( ! std20::constructible_from< int (&)() > ); + CHECK( ! std20::constructible_from< int[] > ); + CHECK( std20::constructible_from< int[2] > ); + CHECK( std20::constructible_from< int const (&)[2], int (&)[2] > ); + CHECK( ! std20::constructible_from< int, int (&)[2] >); + + CHECK( std20::constructible_from< int, int > ); + CHECK( std20::constructible_from< int, int& > ); + CHECK( std20::constructible_from< int, int&& > ); + CHECK( std20::constructible_from< int, const int > ); + CHECK( std20::constructible_from< int, const int& > ); + CHECK( std20::constructible_from< int, const int&& > ); + + CHECK( std20::constructible_from< Foo, Foo > ); + CHECK( std20::constructible_from< Foo, Foo& > ); + CHECK( std20::constructible_from< Foo, Foo&& > ); + CHECK( std20::constructible_from< Foo, const Foo > ); + CHECK( std20::constructible_from< Foo, const Foo& > ); + CHECK( std20::constructible_from< Foo, const Foo&&> ); + + CHECK( ! std20::constructible_from< int&, int > ); + CHECK( std20::constructible_from< int&, int& > ); + CHECK( ! std20::constructible_from< int&, int&& > ); + CHECK( ! std20::constructible_from< int&, const int > ); + CHECK( ! std20::constructible_from< int&, const int& > ); + CHECK( ! std20::constructible_from< int&, const int&& > ); + + CHECK( std20::constructible_from< const int&, int > ); + CHECK( std20::constructible_from< const int&, int& > ); + CHECK( std20::constructible_from< const int&, int&& > ); + CHECK( std20::constructible_from< const int&, const int > ); + CHECK( std20::constructible_from< const int&, const int& > ); + CHECK( std20::constructible_from< const int&, const int&& > ); + + CHECK( std20::constructible_from< int&&, int > ); + CHECK( ! std20::constructible_from< int&&, int& > ); + CHECK( std20::constructible_from< int&&, int&& > ); + CHECK( ! std20::constructible_from< int&&, const int > ); + CHECK( ! std20::constructible_from< int&&, const int& > ); + CHECK( ! std20::constructible_from< int&&, const int&& > ); + + CHECK( std20::constructible_from< const int&&, int > ); + CHECK(! std20::constructible_from< const int&&, int& > ); + CHECK( std20::constructible_from< const int&&, int&& > ); + CHECK( std20::constructible_from< const int&&, const int > ); + CHECK(! std20::constructible_from< const int&&, const int& > ); + CHECK( std20::constructible_from< const int&&, const int&& > ); +} // SCENARIO diff --git a/src/tools/std20/concepts/test/default_initializable.test.cpp b/src/tools/std20/concepts/test/default_initializable.test.cpp new file mode 100644 index 0000000..bceb348 --- /dev/null +++ b/src/tools/std20/concepts/test/default_initializable.test.cpp @@ -0,0 +1,41 @@ +// include Catch2 +#include + +// what we are testing +#include "tools/std20/concepts.hpp" + +// other includes +#include + +// convenience typedefs +//using namespace njoy::tools; +namespace std20 = nano::ranges; + +// test code +struct Foo { + + ~Foo() noexcept {}; +}; + +struct NonDefaultConstructableFoo { + + NonDefaultConstructableFoo() = delete; + ~NonDefaultConstructableFoo() noexcept {}; +}; + +SCENARIO( "default_initializable" ) { + + CHECK( std20::default_initializable< Foo > ); + CHECK( ! std20::default_initializable< NonDefaultConstructableFoo > ); + + CHECK( std20::default_initializable< int > ); + CHECK( ! std20::default_initializable< const int > ); + CHECK( ! std20::default_initializable< int& > ); + CHECK( ! std20::default_initializable< int() > ); + CHECK( ! std20::default_initializable< int (&)() > ); + CHECK( std20::default_initializable< double > ); + CHECK( ! std20::default_initializable< void > ); + CHECK( ! std20::default_initializable< int[] > ); + CHECK( std20::constructible_from< int[2] > ); + CHECK( std20::default_initializable< int[2] > ); +} // SCENARIO diff --git a/src/tools/std20/concepts/test/destructible.test.cpp b/src/tools/std20/concepts/test/destructible.test.cpp new file mode 100644 index 0000000..7e89e2f --- /dev/null +++ b/src/tools/std20/concepts/test/destructible.test.cpp @@ -0,0 +1,57 @@ +// include Catch2 +#include + +// what we are testing +#include "tools/std20/concepts.hpp" + +// other includes +#include + +// convenience typedefs +//using namespace njoy::tools; +namespace std20 = nano::ranges; + +// test code +struct Foo { + + ~Foo() noexcept {}; +}; + +struct IndestructibleFoo { + + ~IndestructibleFoo() = delete; +}; + +struct ThrowingDestructorFoo { + + ~ThrowingDestructorFoo() noexcept(false); +}; + +struct Bar { + + ~Bar() = default; +}; + +SCENARIO( "destructible" ) { + + CHECK( std20::destructible< Foo > ); + CHECK( std20::destructible< Bar > ); + CHECK( std20::destructible< std::string > ); + + CHECK( ! std20::destructible< IndestructibleFoo > ); + CHECK( ! std20::destructible< ThrowingDestructorFoo > ); + + CHECK( std20::destructible< int > ); + CHECK( std20::destructible< const int > ); + + CHECK( std20::destructible< int& > ); + CHECK( std20::destructible< void (*)() > ); + CHECK( std20::destructible< void (&)() > ); + CHECK( std20::destructible< int[2] > ); + CHECK( std20::destructible< int (*)[2] > ); + CHECK( std20::destructible< int (&)[2] > ); + + CHECK( ! std20::destructible< void > ); + CHECK( ! std20::destructible< void() > ); + CHECK( ! std20::destructible< int[] > ); +} // SCENARIO