Skip to content

Commit

Permalink
Improve testcase for resize_uninitialized
Browse files Browse the repository at this point in the history
  • Loading branch information
d-frey committed Nov 5, 2024
1 parent 44fbf90 commit 0d9d993
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/test/pq/resize_uninitialized.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,29 @@ void run()
TEST_ASSERT( s[ 0 ] == 'h' );
TEST_ASSERT( s[ 1 ] == 'e' );

std::vector< std::byte > v = { std::byte( 42 ), std::byte( 69 ) };
test( s, 2 );
TEST_ASSERT( s[ 0 ] == 'h' );
TEST_ASSERT( s[ 1 ] == 'e' );

std::vector< std::byte > v = { static_cast< std::byte >( 42 ), static_cast< std::byte >( 69 ) };
TEST_ASSERT( v.size() == 2 );
TEST_ASSERT( v[ 0 ] == std::byte( 42 ) );
TEST_ASSERT( v[ 1 ] == std::byte( 69 ) );
TEST_ASSERT( v[ 0 ] == static_cast< std::byte >( 42 ) );
TEST_ASSERT( v[ 1 ] == static_cast< std::byte >( 69 ) );

tao::pq::internal::resize_uninitialized( v, 5 );
TEST_ASSERT( v.size() == 5 );
TEST_ASSERT( v[ 0 ] == std::byte( 42 ) );
TEST_ASSERT( v[ 1 ] == std::byte( 69 ) );
TEST_ASSERT( v[ 0 ] == static_cast< std::byte >( 42 ) );
TEST_ASSERT( v[ 1 ] == static_cast< std::byte >( 69 ) );

tao::pq::internal::resize_uninitialized( v, 1000000000 );
TEST_ASSERT( v.size() == 1000000000 );
TEST_ASSERT( v[ 0 ] == std::byte( 42 ) );
TEST_ASSERT( v[ 1 ] == std::byte( 69 ) );
TEST_ASSERT( v[ 0 ] == static_cast< std::byte >( 42 ) );
TEST_ASSERT( v[ 1 ] == static_cast< std::byte >( 69 ) );

tao::pq::internal::resize_uninitialized( v, 2 );
TEST_ASSERT( v.size() == 2 );
TEST_ASSERT( v[ 0 ] == static_cast< std::byte >( 42 ) );
TEST_ASSERT( v[ 1 ] == static_cast< std::byte >( 69 ) );
}

auto main() -> int
Expand Down

0 comments on commit 0d9d993

Please sign in to comment.