Skip to content

Commit

Permalink
Merge branch 'fix/stride-view-vector' into 'develop'
Browse files Browse the repository at this point in the history
Fix/stride view vector

See merge request njoy/tools!5
  • Loading branch information
joewpeterson committed Oct 16, 2024
2 parents af689a4 + c037a60 commit 0133415
Show file tree
Hide file tree
Showing 15 changed files with 382 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/tools/std20/views/test/all.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ SCENARIO( "all_view" ) {
CHECK( std20::ranges::equal( chunk, modified ) );
CHECK( std20::ranges::equal( values, modified ) );
} // THEN

THEN( "it can be transformed into a vector using iterators" ) {

std::vector< int > constructed( chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( constructed, chunk ) );

std::vector< int > inserted;
inserted.insert( inserted.end(), chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( inserted, chunk ) );
}
} // WHEN
} // GIVEN

Expand Down Expand Up @@ -145,6 +155,16 @@ SCENARIO( "all_view" ) {
CHECK( std20::ranges::equal( chunk, modified ) );
CHECK( std20::ranges::equal( values, modified ) );
} // THEN

THEN( "it can be transformed into a vector using iterators" ) {

std::vector< int > constructed( chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( constructed, chunk ) );

std::vector< int > inserted;
inserted.insert( inserted.end(), chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( inserted, chunk ) );
}
} // WHEN
} // GIVEN

Expand Down Expand Up @@ -217,6 +237,16 @@ SCENARIO( "all_view" ) {
CHECK( 4 == chunk[3] );
CHECK( 6 == chunk[4] );
} // THEN

THEN( "it can be transformed into a vector using iterators" ) {

std::vector< int > constructed( chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( constructed, chunk ) );

std::vector< int > inserted;
inserted.insert( inserted.end(), chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( inserted, chunk ) );
}
} // WHEN
} // GIVEN
} // SCENARIO
10 changes: 10 additions & 0 deletions src/tools/std20/views/test/counted.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@ SCENARIO( "counted_view" ) {
CHECK( 0 == chunk[1] );
CHECK( 2 == chunk[2] );
} // THEN

THEN( "it can be transformed into a vector using iterators" ) {

std::vector< int > constructed( chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( constructed, chunk ) );

std::vector< int > inserted;
inserted.insert( inserted.end(), chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( inserted, chunk ) );
}
} // WHEN
} // GIVEN
} // SCENARIO
30 changes: 30 additions & 0 deletions src/tools/std20/views/test/drop.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ SCENARIO( "drop_view" ) {
CHECK( std20::ranges::equal( chunk, modified ) );
CHECK( std20::ranges::equal( values, original_modified ) );
} // THEN

THEN( "it can be transformed into a vector using iterators" ) {

std::vector< int > constructed( chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( constructed, chunk ) );

std::vector< int > inserted;
inserted.insert( inserted.end(), chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( inserted, chunk ) );
}
} // WHEN
} // GIVEN

Expand Down Expand Up @@ -137,6 +147,16 @@ SCENARIO( "drop_view" ) {
CHECK( std20::ranges::equal( chunk, modified ) );
CHECK( std20::ranges::equal( values, original_modified ) );
} // THEN

THEN( "it can be transformed into a vector using iterators" ) {

std::vector< int > constructed( chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( constructed, chunk ) );

std::vector< int > inserted;
inserted.insert( inserted.end(), chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( inserted, chunk ) );
}
} // WHEN
} // GIVEN

Expand Down Expand Up @@ -202,6 +222,16 @@ SCENARIO( "drop_view" ) {
CHECK( 2 == chunk[1] );
CHECK( 4 == chunk[2] );
} // THEN

THEN( "it can be transformed into a vector using iterators" ) {

std::vector< int > constructed( chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( constructed, chunk ) );

std::vector< int > inserted;
inserted.insert( inserted.end(), chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( inserted, chunk ) );
}
} // WHEN
} // GIVEN
} // SCENARIO
30 changes: 30 additions & 0 deletions src/tools/std20/views/test/drop_while.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ SCENARIO( "drop_while_view" ) {
// the following should not compile: no random access iterator
// CHECK( 2 == chunk.back() );
} // THEN

THEN( "it can be transformed into a vector using iterators" ) {

std::vector< int > constructed( chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( constructed, chunk ) );

std::vector< int > inserted;
inserted.insert( inserted.end(), chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( inserted, chunk ) );
}
} // WHEN
} // GIVEN

Expand Down Expand Up @@ -116,6 +126,16 @@ SCENARIO( "drop_while_view" ) {
// the following should not compile: no random access iterator
// CHECK( -2 == chunk[0] );
} // THEN

THEN( "it can be transformed into a vector using iterators" ) {

std::vector< int > constructed( chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( constructed, chunk ) );

std::vector< int > inserted;
inserted.insert( inserted.end(), chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( inserted, chunk ) );
}
} // WHEN
} // GIVEN

Expand Down Expand Up @@ -166,6 +186,16 @@ SCENARIO( "drop_while_view" ) {
CHECK( 0 == chunk.front() );
CHECK( 2 == chunk.back() );
} // THEN

THEN( "it can be transformed into a vector using iterators" ) {

std::vector< int > constructed( chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( constructed, chunk ) );

std::vector< int > inserted;
inserted.insert( inserted.end(), chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( inserted, chunk ) );
}
} // WHEN
} // GIVEN
} // SCENARIO
30 changes: 30 additions & 0 deletions src/tools/std20/views/test/filter.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ SCENARIO( "filter_view" ) {
CHECK( std20::ranges::equal( chunk, modified ) );
CHECK( std20::ranges::equal( values, original_modified ) );
} // THEN

THEN( "it can be transformed into a vector using iterators" ) {

std::vector< int > constructed( chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( constructed, chunk ) );

std::vector< int > inserted;
inserted.insert( inserted.end(), chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( inserted, chunk ) );
}
} // WHEN
} // GIVEN

Expand Down Expand Up @@ -140,6 +150,16 @@ SCENARIO( "filter_view" ) {
CHECK( std20::ranges::equal( chunk, modified ) );
CHECK( std20::ranges::equal( values, original_modified ) );
} // THEN

THEN( "it can be transformed into a vector using iterators" ) {

std::vector< int > constructed( chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( constructed, chunk ) );

std::vector< int > inserted;
inserted.insert( inserted.end(), chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( inserted, chunk ) );
}
} // WHEN
} // GIVEN

Expand Down Expand Up @@ -204,6 +224,16 @@ SCENARIO( "filter_view" ) {
CHECK( std20::ranges::equal( chunk, modified ) );
CHECK( std20::ranges::equal( values, original_modified ) );
} // THEN

THEN( "it can be transformed into a vector using iterators" ) {

std::vector< int > constructed( chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( constructed, chunk ) );

std::vector< int > inserted;
inserted.insert( inserted.end(), chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( inserted, chunk ) );
}
} // WHEN
} // GIVEN*/
} // SCENARIO
20 changes: 20 additions & 0 deletions src/tools/std20/views/test/iota.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ SCENARIO( "iota_view" ) {
CHECK( *( begin + 5 ) == 6 );
CHECK( *( begin + 99 ) == 100 );
} // THEN

// THEN( "it can be transformed into a vector using iterators" ) {
//
// std::vector< int > constructed( chunk.begin(), chunk.end() );
// CHECK( std20::ranges::equal( constructed, chunk ) );
//
// std::vector< int > inserted;
// inserted.insert( inserted.end(), chunk.begin(), chunk.end() );
// CHECK( std20::ranges::equal( inserted, chunk ) );
// }
} // WHEN
} // GIVEN

Expand Down Expand Up @@ -139,6 +149,16 @@ SCENARIO( "iota_view" ) {
CHECK( *( begin + 1 ) == 2 );
CHECK( *( end - 1 ) == 5 );
} // THEN

// THEN( "it can be transformed into a vector using iterators" ) {
//
// std::vector< int > constructed( chunk.begin(), chunk.end() );
// CHECK( std20::ranges::equal( constructed, chunk ) );
//
// std::vector< int > inserted;
// inserted.insert( inserted.end(), chunk.begin(), chunk.end() );
// CHECK( std20::ranges::equal( inserted, chunk ) );
// }
} // WHEN
} // GIVEN
} // SCENARIO
30 changes: 30 additions & 0 deletions src/tools/std20/views/test/join.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ SCENARIO( "join_view" ) {

CHECK( std20::ranges::equal( chunk, modified ) );
} // THEN

THEN( "it can be transformed into a vector using iterators" ) {

std::vector< int > constructed( chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( constructed, chunk ) );

std::vector< int > inserted;
inserted.insert( inserted.end(), chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( inserted, chunk ) );
}
} // WHEN
} // GIVEN

Expand Down Expand Up @@ -123,6 +133,16 @@ SCENARIO( "join_view" ) {

CHECK( std20::ranges::equal( chunk, modified ) );
} // THEN

THEN( "it can be transformed into a vector using iterators" ) {

std::vector< int > constructed( chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( constructed, chunk ) );

std::vector< int > inserted;
inserted.insert( inserted.end(), chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( inserted, chunk ) );
}
} // WHEN
} // GIVEN

Expand Down Expand Up @@ -177,6 +197,16 @@ SCENARIO( "join_view" ) {

CHECK( std20::ranges::equal( chunk, modified ) );
} // THEN

THEN( "it can be transformed into a vector using iterators" ) {

std::vector< int > constructed( chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( constructed, chunk ) );

std::vector< int > inserted;
inserted.insert( inserted.end(), chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( inserted, chunk ) );
}
} // WHEN
} // GIVEN
} // SCENARIO
30 changes: 30 additions & 0 deletions src/tools/std20/views/test/ref.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ SCENARIO( "ref_view" ) {
CHECK( std20::ranges::equal( chunk, modified ) );
CHECK( std20::ranges::equal( values, modified ) );
} // THEN

THEN( "it can be transformed into a vector using iterators" ) {

std::vector< int > constructed( chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( constructed, chunk ) );

std::vector< int > inserted;
inserted.insert( inserted.end(), chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( inserted, chunk ) );
}
} // WHEN
} // GIVEN

Expand Down Expand Up @@ -145,6 +155,16 @@ SCENARIO( "ref_view" ) {
CHECK( std20::ranges::equal( chunk, modified ) );
CHECK( std20::ranges::equal( values, modified ) );
} // THEN

THEN( "it can be transformed into a vector using iterators" ) {

std::vector< int > constructed( chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( constructed, chunk ) );

std::vector< int > inserted;
inserted.insert( inserted.end(), chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( inserted, chunk ) );
}
} // WHEN
} // GIVEN

Expand Down Expand Up @@ -216,6 +236,16 @@ SCENARIO( "ref_view" ) {
CHECK( 4 == chunk[3] );
CHECK( 6 == chunk[4] );
} // THEN

THEN( "it can be transformed into a vector using iterators" ) {

std::vector< int > constructed( chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( constructed, chunk ) );

std::vector< int > inserted;
inserted.insert( inserted.end(), chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( inserted, chunk ) );
}
} // WHEN
} // GIVEN
} // SCENARIO
20 changes: 20 additions & 0 deletions src/tools/std20/views/test/reverse.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ SCENARIO( "reverse_view" ) {
CHECK( std20::ranges::equal( chunk, modified ) );
CHECK( std20::ranges::equal( values, modified ) );
} // THEN

THEN( "it can be transformed into a vector using iterators" ) {

std::vector< int > constructed( chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( constructed, chunk ) );

std::vector< int > inserted;
inserted.insert( inserted.end(), chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( inserted, chunk ) );
}
} // WHEN
} // GIVEN

Expand Down Expand Up @@ -144,6 +154,16 @@ SCENARIO( "reverse_view" ) {
CHECK( 2 == chunk[3] );
CHECK( 2 == chunk[4] );
} // THEN

THEN( "it can be transformed into a vector using iterators" ) {

std::vector< int > constructed( chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( constructed, chunk ) );

std::vector< int > inserted;
inserted.insert( inserted.end(), chunk.begin(), chunk.end() );
CHECK( std20::ranges::equal( inserted, chunk ) );
}
} // WHEN
} // GIVEN
} // SCENARIO
Loading

0 comments on commit 0133415

Please sign in to comment.