-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathstep_definition.cpp
More file actions
85 lines (77 loc) · 2.42 KB
/
Copy pathstep_definition.cpp
File metadata and controls
85 lines (77 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "../src/cucumber.hpp"
#include "box.hpp"
GIVEN(box_init_empty, "An empty box")
{
const box& my_box = cuke::context<box>();
cuke::equal(my_box.items_count(), 0);
}
GIVEN(box_with_label, "An empty box with a label")
{
std::string label = CUKE_DOC_STRING();
cuke::context<box>(label);
}
WHEN(add_item, "I place {int} x {string} in it")
{
const std::size_t count = CUKE_ARG(1);
const std::string item = CUKE_ARG(2);
cuke::context<box>().add_items(item, count);
}
WHEN(coords, "I have {int},{int} as coordinates")
{
const int x = CUKE_ARG(1);
const int y = CUKE_ARG(2);
std::cout << "given coordinates x=" << x << " y=" << y << '\n';
}
WHEN(add_table_raw, "I add all items with the raw function:")
{
const cuke::table& t = CUKE_TABLE();
for (const cuke::table::row& row : t.raw())
{
cuke::context<box>().add_items(row[0].to_string(), row[1].as<long>());
}
}
WHEN(add_table_hashes, "I add all items with the hashes function:")
{
const cuke::table& t = CUKE_TABLE();
for (const auto& row : t.hashes())
{
cuke::context<box>().add_items(row["ITEM"].to_string(),
row["QUANTITY"].as<long>());
}
}
WHEN(add_table_rows_hash,
"I add the following item with the rows_hash function:")
{
const cuke::table& t = CUKE_TABLE();
cuke::table::pair hash_rows = t.rows_hash();
cuke::context<box>().add_items(hash_rows["ITEM"].to_string(),
hash_rows["QUANTITY"].as<long>());
}
THEN(box_is_labeled, "The box is labeled")
{
cuke::is_false(cuke::context<box>().label().empty());
}
THEN(box_item_at_index, "The {int}. item is {string}")
{
const std::size_t number = CUKE_ARG(1);
const std::size_t idx_zero_based = number - 1;
const std::string item = CUKE_ARG(2);
cuke::equal(item, cuke::context<box>().at(idx_zero_based));
}
THEN(box_count_items, "The box contains {int} item(s)")
{
const int items_count = CUKE_ARG(1);
const box& my_box = cuke::context<box>();
cuke::equal(my_box.items_count(), items_count);
}
THEN(box_find_item, "{word} is/are in the box")
{
const std::string item = CUKE_ARG(1);
cuke::is_true(cuke::context<box>().contains(item));
}
THEN(box_count_items_alternative, "{int} item(s) is/are {string}")
{
const std::size_t count = CUKE_ARG(1);
const std::string item = CUKE_ARG(2);
cuke::equal(count, cuke::context<box>().count(item));
}