-
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
5 changed files
with
123 additions
and
8 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,5 +1,8 @@ | ||
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 ) | ||
add_cpp_test( std20.concepts.same_as same_as.test.cpp ) | ||
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.equality_comparable equality_comparable.test.cpp ) | ||
add_cpp_test( std20.concepts.totally_ordered totally_ordered.test.cpp ) |
56 changes: 56 additions & 0 deletions
56
src/tools/std20/concepts/test/common_reference_with.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,56 @@ | ||
// 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( "common_reference_with" ) { | ||
|
||
CHECK( std20::common_reference_with< Foo, Foo > ); | ||
CHECK( std20::common_reference_with< Bar, Foo > ); | ||
CHECK( std20::common_reference_with< Foo, Bar > ); | ||
CHECK( std20::common_reference_with< Bar, Bar > ); | ||
CHECK( std20::common_reference_with< int, double > ); | ||
CHECK( std20::common_reference_with< double, int > ); | ||
CHECK( std20::common_reference_with< void, void > ); | ||
|
||
CHECK( std20::common_reference_with< int&, int& > ); | ||
CHECK( std20::common_reference_with< const int&, int& > ); | ||
CHECK( std20::common_reference_with< int&, const int& > ); | ||
CHECK( std20::common_reference_with< int&&, int& > ); | ||
CHECK( std20::common_reference_with< int&&, const int& > ); | ||
CHECK( std20::common_reference_with< int&, int&& > ); | ||
CHECK( std20::common_reference_with< const int&, int&& > ); | ||
CHECK( std20::common_reference_with< int&&, int&& > ); | ||
CHECK( std20::common_reference_with< const int&&, int&& > ); | ||
CHECK( std20::common_reference_with< int&&, const int&& > ); | ||
|
||
CHECK( std20::common_reference_with< volatile int&, int& > ); | ||
CHECK( std20::common_reference_with< volatile int&, const int& > ); | ||
CHECK( std20::common_reference_with< const volatile int&, int& > ); | ||
CHECK( std20::common_reference_with< int&, volatile int& > ); | ||
CHECK( std20::common_reference_with< const int&, volatile int& > ); | ||
CHECK( std20::common_reference_with< int&, const volatile int& > ); | ||
|
||
CHECK( std20::common_reference_with< Foo&, Bar& > ); | ||
CHECK( std20::common_reference_with< Foo&&, Bar&& > ); | ||
CHECK( std20::common_reference_with< Foo&, Bar&& > ); | ||
CHECK( std20::common_reference_with< Foo&&, Bar& > ); | ||
CHECK( std20::common_reference_with< Foo&&, Bar&& > ); | ||
|
||
CHECK( ! std20::common_reference_with< AlsoBar, Foo > ); // private inheritance from Foo | ||
CHECK( ! std20::common_reference_with< Foo, AlsoBar > ); // private inheritance from Foo | ||
} // 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,56 @@ | ||
// 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( "common_with" ) { | ||
|
||
CHECK( std20::common_with< Foo, Foo > ); | ||
CHECK( std20::common_with< Bar, Foo > ); | ||
CHECK( std20::common_with< Foo, Bar > ); | ||
CHECK( std20::common_with< Bar, Bar > ); | ||
CHECK( std20::common_with< int, double > ); | ||
CHECK( std20::common_with< double, int > ); | ||
CHECK( std20::common_with< void, void > ); | ||
|
||
CHECK( std20::common_with< int&, int& > ); | ||
CHECK( std20::common_with< const int&, int& > ); | ||
CHECK( std20::common_with< int&, const int& > ); | ||
CHECK( std20::common_with< int&&, int& > ); | ||
CHECK( std20::common_with< int&&, const int& > ); | ||
CHECK( std20::common_with< int&, int&& > ); | ||
CHECK( std20::common_with< const int&, int&& > ); | ||
CHECK( std20::common_with< int&&, int&& > ); | ||
CHECK( std20::common_with< const int&&, int&& > ); | ||
CHECK( std20::common_with< int&&, const int&& > ); | ||
|
||
CHECK( std20::common_with< volatile int&, int& > ); | ||
CHECK( std20::common_with< volatile int&, const int& > ); | ||
CHECK( std20::common_with< const volatile int&, int& > ); | ||
CHECK( std20::common_with< int&, volatile int& > ); | ||
CHECK( std20::common_with< const int&, volatile int& > ); | ||
CHECK( std20::common_with< int&, const volatile int& > ); | ||
|
||
CHECK( std20::common_with< Foo&, Bar& > ); | ||
CHECK( std20::common_with< Foo&&, Bar&& > ); | ||
CHECK( std20::common_with< Foo&, Bar&& > ); | ||
CHECK( std20::common_with< Foo&&, Bar& > ); | ||
CHECK( std20::common_with< Foo&&, Bar&& > ); | ||
|
||
CHECK( ! std20::common_with< AlsoBar, Foo > ); // private inheritance from Foo | ||
CHECK( ! std20::common_with< Foo, AlsoBar > ); // private inheritance from Foo | ||
} // 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
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