blob: 1cf4b3b2a20b7ea5929e3940bb230a4feb215ecf [file] [log] [blame]
onqtame4c75fc2016-05-21 01:24:48 +03001#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
2#include "doctest.h"
3
4#include <iostream>
5#include <vector>
6using namespace std;
7
8TEST_CASE("lots of nested subcases") {
9 cout << endl << "root" << endl;
10 SUBCASE("") {
11 cout << "1" << endl;
12 SUBCASE("") { cout << "1.1" << endl; }
13 }
14 SUBCASE("") {
15 cout << "2" << endl;
16 SUBCASE("") { cout << "2.1" << endl; }
17 SUBCASE("") {
18 cout << "2.2" << endl;
19 SUBCASE("") {
20 cout << "2.2.1" << endl;
21 SUBCASE("") { cout << "2.2.1.1" << endl; }
22 SUBCASE("") { cout << "2.2.1.2" << endl; }
23 }
24 }
25 SUBCASE("") { cout << "2.3" << endl; }
26 SUBCASE("") { cout << "2.4" << endl; }
27 }
28}
29
30SCENARIO("vectors can be sized and resized") {
31 GIVEN("A vector with some items") {
32 std::vector<int> v(5);
33
34 REQUIRE(v.size() == 5u);
35 REQUIRE(v.capacity() >= 5u);
36
37 WHEN("the size is increased") {
38 v.resize(10u);
39
40 THEN("the size and capacity change") {
41 CHECK(v.size() == 20u);
42 CHECK(v.capacity() >= 10u);
43 }
44 }
45 WHEN("the size is reduced") {
46 v.resize(0);
47
48 THEN("the size changes but not capacity") {
49 CHECK(v.size() == 0u);
50 CHECK(v.capacity() >= 5u);
51 }
52 }
53 WHEN("more capacity is reserved") {
54 v.reserve(10);
55
56 THEN("the capacity changes but not the size") {
57 CHECK(v.size() == 5u);
58 CHECK(v.capacity() >= 10u);
59 }
60 }
61 WHEN("less capacity is reserved") {
62 v.reserve(0);
63
64 THEN("neither size nor capacity are changed") {
65 CHECK(v.size() == 10u);
66 CHECK(v.capacity() >= 5u);
67 }
68 }
69 }
70}