Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
100-Fix-Section.cpp File Reference
#include <catch2/catch.hpp>
Include dependency graph for 100-Fix-Section.cpp:

Go to the source code of this file.

Functions

 TEST_CASE ("vectors can be sized and resized", "[vector]")
 

Function Documentation

◆ TEST_CASE()

TEST_CASE ( "vectors can be sized and resized" ,
"" [vector] )

Definition at line 11 of file 100-Fix-Section.cpp.

11 {
12
13 // For each section, vector v is anew:
14
15 std::vector<int> v( 5 );
16
17 REQUIRE( v.size() == 5 );
18 REQUIRE( v.capacity() >= 5 );
19
20 SECTION( "resizing bigger changes size and capacity" ) {
21 v.resize( 10 );
22
23 REQUIRE( v.size() == 10 );
24 REQUIRE( v.capacity() >= 10 );
25 }
26 SECTION( "resizing smaller changes size but not capacity" ) {
27 v.resize( 0 );
28
29 REQUIRE( v.size() == 0 );
30 REQUIRE( v.capacity() >= 5 );
31 }
32 SECTION( "reserving bigger changes capacity but not size" ) {
33 v.reserve( 10 );
34
35 REQUIRE( v.size() == 5 );
36 REQUIRE( v.capacity() >= 10 );
37 }
38 SECTION( "reserving smaller does not change size or capacity" ) {
39 v.reserve( 0 );
40
41 REQUIRE( v.size() == 5 );
42 REQUIRE( v.capacity() >= 5 );
43 }
44}
#define SECTION(...)
Definition catch.hpp:226
#define REQUIRE(...)
Definition catch.hpp:185