Created
June 11, 2019 15:40
-
-
Save junaidrahim/0a823b395219047ab9e3d61e76b964c0 to your computer and use it in GitHub Desktop.
Test cases and sections from the catch2 github repo
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
TEST_CASE( "vectors can be sized and resized", "[vector]" ) { | |
std::vector<int> v( 5 ); | |
REQUIRE( v.size() == 5 ); | |
REQUIRE( v.capacity() >= 5 ); | |
SECTION( "resizing bigger changes size and capacity" ) { | |
v.resize( 10 ); | |
REQUIRE( v.size() == 10 ); | |
REQUIRE( v.capacity() >= 10 ); | |
} | |
SECTION( "resizing smaller changes size but not capacity" ) { | |
v.resize( 0 ); | |
REQUIRE( v.size() == 0 ); | |
REQUIRE( v.capacity() >= 5 ); | |
} | |
SECTION( "reserving bigger changes capacity but not size" ) { | |
v.reserve( 10 ); | |
REQUIRE( v.size() == 5 ); | |
REQUIRE( v.capacity() >= 10 ); | |
} | |
SECTION( "reserving smaller does not change size or capacity" ) { | |
v.reserve( 0 ); | |
REQUIRE( v.size() == 5 ); | |
REQUIRE( v.capacity() >= 5 ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment