| 30 | }; |
| 31 | |
| 32 | int main(int argc, const char** argv) { |
| 33 | using namespace boost::ut; |
| 34 | |
| 35 | bdd::gherkin::steps steps = [](auto& steps) { |
| 36 | steps.feature("Calculator") = [&] { |
| 37 | steps.scenario("*") = [&] { |
| 38 | steps.given("I have calculator") = [&] { |
| 39 | calculator<int> calc{}; |
| 40 | steps.when("I enter {value}") = [&](int value) { calc.enter(value); }; |
| 41 | steps.when("I press add") = [&] { calc.add(); }; |
| 42 | steps.when("I press sub") = [&] { calc.sub(); }; |
| 43 | steps.then("I expect {value}") = [&](int result) { |
| 44 | expect(that % calc.get() == result); |
| 45 | }; |
| 46 | }; |
| 47 | }; |
| 48 | }; |
| 49 | }; |
| 50 | |
| 51 | // clang-format off |
| 52 | "Calculator"_test = steps | |
| 53 | R"( |
| 54 | Feature: Calculator |
| 55 | |
| 56 | Scenario: Addition |
| 57 | Given I have calculator |
| 58 | When I enter 40 |
| 59 | When I enter 2 |
| 60 | When I press add |
| 61 | Then I expect 42 |
| 62 | |
| 63 | Scenario: Subtraction |
| 64 | Given I have calculator |
| 65 | When I enter 4 |
| 66 | When I enter 2 |
| 67 | When I press sub |
| 68 | Then I expect 2 |
| 69 | )"; |
| 70 | // clang-format on |
| 71 | |
| 72 | if (argc == 2) { |
| 73 | const auto file = [](const auto path) { |
| 74 | std::ifstream file{path}; |
| 75 | return std::string{(std::istreambuf_iterator<char>(file)), |
| 76 | std::istreambuf_iterator<char>()}; |
| 77 | }; |
| 78 | |
| 79 | "Calculator"_test = steps | file(argv[1]); |
| 80 | } |
| 81 | } |