Skip to content

Commit

Permalink
Updating tests
Browse files Browse the repository at this point in the history
  • Loading branch information
whaeck committed Feb 1, 2024
1 parent 3367e36 commit a414687
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 16 deletions.
56 changes: 42 additions & 14 deletions src/tools/nanorange/views/iota/test/iota.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,21 @@ TEST_CASE("views.iota")
static_assert(*(it1 + 1) == 1);
static_assert(*(it2 - 1) == 9);

constexpr auto compound_assignment_test = [rng] {
auto it = rng.begin();
it += 3;
if (*it != 3) {
return false;
}
it -= 3;
if (it != rng.begin()) {
return false;
}
return true;
};

static_assert(compound_assignment_test());
// does not compile with intel-classic/2022 (error: expression must have a constant value)
// constexpr auto compound_assignment_test = [rng] {
// auto it = rng.begin();
// it += 3;
// if (*it != 3) {
// return false;
// }
// it -= 3;
// if (it != rng.begin()) {
// return false;
// }
// return true;
// };
//
// static_assert(compound_assignment_test());
}

// {
Expand Down Expand Up @@ -88,3 +89,30 @@ TEST_CASE("views.iota")
// Additional tests
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

SCENARIO( "std::ranges::views::iota" ) {

auto chunk = nano::views::iota( 0, 5 );

THEN( "an iota view can be constructed and members can be tested" ) {

CHECK( 5 == chunk.size() );
CHECK( false == chunk.empty() );
CHECK( true == bool( chunk ) );

unsigned int counter = 0;
for ( auto value : chunk ) {

++counter;
}
CHECK( 5 == counter );

CHECK( 0 == chunk[0] );
CHECK( 1 == chunk[1] );
CHECK( 2 == chunk[2] );
CHECK( 3 == chunk[3] );
CHECK( 4 == chunk[4] );

CHECK( 0 == chunk.front() );
CHECK( 4 == chunk.back() );
} // THEN
} // SCENARIO
2 changes: 1 addition & 1 deletion src/tools/nanorange/views/subrange/test/subrange.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ TEST_CASE("nanorange.views.subrange") {
// Additional tests
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

SCENARIO( "std::subrange" ) {
SCENARIO( "std::ranges::views::subrange" ) {

GIVEN( "a container with forward iterators" ) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// Additional tests
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

SCENARIO( "TransformView" ) {
SCENARIO( "std::ranges::views::transform" ) {

auto transform = [] ( auto&& value ) { return value - 2; };

Expand Down

0 comments on commit a414687

Please sign in to comment.