Skip to content

Commit

Permalink
More concept testing
Browse files Browse the repository at this point in the history
  • Loading branch information
whaeck committed Feb 26, 2024
1 parent a0e3eb8 commit 2d4415b
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/tools/std20/concepts/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ add_cpp_test( std20.concepts.derived_from derived_from.test.cpp )
add_cpp_test( std20.concepts.convertible_to convertible_to.test.cpp )
add_cpp_test( std20.concepts.common_reference_with common_reference_with.test.cpp )
add_cpp_test( std20.concepts.common_with common_with.test.cpp )
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.equality_comparable equality_comparable.test.cpp )
add_cpp_test( std20.concepts.totally_ordered totally_ordered.test.cpp )
26 changes: 26 additions & 0 deletions src/tools/std20/concepts/test/floating_point.test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// include Catch2
#include <catch2/catch_test_macros.hpp>

// what we are testing
#include "tools/std20/concepts.hpp"

// other includes

// convenience typedefs
//using namespace njoy::tools;
namespace std20 = nano::ranges;

SCENARIO( "floating_point" ) {

CHECK( std20::floating_point< float > );
CHECK( std20::floating_point< double > );

CHECK( ! std20::floating_point< bool > );
CHECK( ! std20::floating_point< char > );
CHECK( ! std20::floating_point< int > );
CHECK( ! std20::floating_point< unsigned int > );
CHECK( ! std20::floating_point< std::ptrdiff_t > );
CHECK( ! std20::floating_point< std::size_t > );
CHECK( ! std20::floating_point< decltype("") > );
CHECK( ! std20::floating_point< void > );
} // SCENARIO
25 changes: 25 additions & 0 deletions src/tools/std20/concepts/test/integral.test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// include Catch2
#include <catch2/catch_test_macros.hpp>

// what we are testing
#include "tools/std20/concepts.hpp"

// other includes

// convenience typedefs
//using namespace njoy::tools;
namespace std20 = nano::ranges;

SCENARIO( "integral" ) {

CHECK( std20::integral< bool > );
CHECK( std20::integral< char > );
CHECK( std20::integral< int > );
CHECK( std20::integral< unsigned int > );
CHECK( std20::integral< std::ptrdiff_t > );
CHECK( std20::integral< std::size_t > );

CHECK( ! std20::integral< double > );
CHECK( ! std20::integral< decltype("") > );
CHECK( ! std20::integral< void > );
} // SCENARIO
24 changes: 24 additions & 0 deletions src/tools/std20/concepts/test/signed_integral.test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// include Catch2
#include <catch2/catch_test_macros.hpp>

// what we are testing
#include "tools/std20/concepts.hpp"

// other includes

// convenience typedefs
//using namespace njoy::tools;
namespace std20 = nano::ranges;

SCENARIO( "signed_integral" ) {

CHECK( std20::signed_integral< int > );
CHECK( std20::signed_integral< std::ptrdiff_t > );

CHECK( ! std20::signed_integral< std::size_t > );
CHECK( ! std20::signed_integral< bool > );
CHECK( ! std20::signed_integral< unsigned int > );
CHECK( ! std20::signed_integral< double > );
CHECK( ! std20::signed_integral< decltype("") > );
CHECK( ! std20::signed_integral< void > );
} // SCENARIO
25 changes: 25 additions & 0 deletions src/tools/std20/concepts/test/unsigned_integral.test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// include Catch2
#include <catch2/catch_test_macros.hpp>

// what we are testing
#include "tools/std20/concepts.hpp"

// other includes

// convenience typedefs
//using namespace njoy::tools;
namespace std20 = nano::ranges;

SCENARIO( "unsigned_integral" ) {

CHECK( std20::unsigned_integral< bool > );
CHECK( std20::unsigned_integral< unsigned int > );
CHECK( std20::unsigned_integral< std::size_t > );

CHECK( ! std20::unsigned_integral< std::ptrdiff_t > );
CHECK( ! std20::unsigned_integral< char > );
CHECK( ! std20::unsigned_integral< int > );
CHECK( ! std20::unsigned_integral< double > );
CHECK( ! std20::unsigned_integral< decltype("") > );
CHECK( ! std20::unsigned_integral< void > );
} // SCENARIO

0 comments on commit 2d4415b

Please sign in to comment.