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

Go to the source code of this file.

Functions

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

Function Documentation

◆ SCENARIO()

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

Definition at line 7 of file 120-Bdd-ScenarioGivenWhenThen.cpp.

7 {
8
9 GIVEN( "A vector with some items" ) {
10 std::vector<int> v( 5 );
11
12 REQUIRE( v.size() == 5 );
13 REQUIRE( v.capacity() >= 5 );
14
15 WHEN( "the size is increased" ) {
16 v.resize( 10 );
17
18 THEN( "the size and capacity change" ) {
19 REQUIRE( v.size() == 10 );
20 REQUIRE( v.capacity() >= 10 );
21 }
22 }
23 WHEN( "the size is reduced" ) {
24 v.resize( 0 );
25
26 THEN( "the size changes but not capacity" ) {
27 REQUIRE( v.size() == 0 );
28 REQUIRE( v.capacity() >= 5 );
29 }
30 }
31 WHEN( "more capacity is reserved" ) {
32 v.reserve( 10 );
33
34 THEN( "the capacity changes but not the size" ) {
35 REQUIRE( v.size() == 5 );
36 REQUIRE( v.capacity() >= 10 );
37 }
38 }
39 WHEN( "less capacity is reserved" ) {
40 v.reserve( 0 );
41
42 THEN( "neither size nor capacity are changed" ) {
43 REQUIRE( v.size() == 5 );
44 REQUIRE( v.capacity() >= 5 );
45 }
46 }
47 }
48}
#define THEN(desc)
Definition catch.hpp:266
#define GIVEN(desc)
Definition catch.hpp:262
#define WHEN(desc)
Definition catch.hpp:264
#define REQUIRE(...)
Definition catch.hpp:185