-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
add_cpp_test( std20.concepts.convertible_to convertible_to.test.cpp ) | ||
add_cpp_test( std20.concepts.derived_from derived_from.test.cpp ) | ||
add_cpp_test( std20.concepts.equality_comparable equality_comparable.test.cpp ) | ||
add_cpp_test( std20.concepts.same_as same_as.test.cpp ) | ||
add_cpp_test( std20.concepts.totally_ordered totally_ordered.test.cpp ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// 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; | ||
|
||
// test code | ||
struct Foo {}; | ||
|
||
struct Bar : public Foo {}; | ||
|
||
struct AlsoBar : private Foo {}; | ||
|
||
SCENARIO( "derived_from" ) { | ||
|
||
CHECK( std20::convertible_to< Foo, Foo > ); | ||
CHECK( std20::convertible_to< Bar, Foo > ); | ||
CHECK( std20::convertible_to< int, double > ); | ||
CHECK( std20::convertible_to< double, int > ); | ||
CHECK( std20::convertible_to< void, void > ); | ||
|
||
CHECK( ! std20::convertible_to< Foo, Bar > ); // Foo is not derived from Bar | ||
CHECK( ! std20::convertible_to< AlsoBar, Foo > ); // private inheritance from Bar | ||
} // SCENARIO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// 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; | ||
|
||
// test code | ||
struct Foo {}; | ||
|
||
struct Bar : public Foo {}; | ||
|
||
struct AlsoBar : private Foo {}; | ||
|
||
SCENARIO( "derived_from" ) { | ||
|
||
CHECK( std20::derived_from< Foo, Foo > ); | ||
CHECK( std20::derived_from< Bar, Foo > ); | ||
|
||
CHECK( ! std20::derived_from< int, double > ); // different primitive types | ||
CHECK( ! std20::derived_from< int, int > ); // same primitive types | ||
CHECK( ! std20::derived_from< double, double > ); // same primitive types | ||
CHECK( ! std20::derived_from< Foo, Bar > ); // Foo is not derived from Bar | ||
CHECK( ! std20::derived_from< AlsoBar, Foo > ); // private inheritance from Bar | ||
} // SCENARIO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// 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; | ||
|
||
// test code | ||
struct Foo {}; | ||
|
||
struct Bar {}; | ||
|
||
SCENARIO( "same_as" ) { | ||
|
||
CHECK( std20::same_as< int, int > ); | ||
CHECK( std20::same_as< double, double > ); | ||
CHECK( std20::same_as< Foo, Foo > ); | ||
|
||
CHECK( std20::same_as< std::common_type_t< int, int, int >, int > ); | ||
CHECK( std20::same_as< std::common_type_t< int, float, double >, double > ); | ||
|
||
CHECK( ! std20::same_as< double, int > ); | ||
CHECK( ! std20::same_as< int, double > ); | ||
CHECK( ! std20::same_as< Foo, Bar > ); | ||
} // SCENARIO |