|
| 1 | +#include "kindergarten_garden.h" |
| 2 | +#ifdef EXERCISM_TEST_SUITE |
| 3 | +#include <catch2/catch.hpp> |
| 4 | +#else |
| 5 | +#include "test/catch.hpp" |
| 6 | +#endif |
| 7 | + |
| 8 | +// improves error messages with triangle flavor enum text instead of integers: |
| 9 | +CATCH_REGISTER_ENUM(kindergarten_garden::Plants, |
| 10 | + kindergarten_garden::Plants::clover, |
| 11 | + kindergarten_garden::Plants::grass, |
| 12 | + kindergarten_garden::Plants::violets, |
| 13 | + kindergarten_garden::Plants::radishes) |
| 14 | + |
| 15 | +TEST_CASE("garden with single student", "[1fc316ed-17ab-4fba-88ef-3ae78296b692]") { |
| 16 | + std::array<kindergarten_garden::Plants, 4> expected{kindergarten_garden::Plants::radishes, kindergarten_garden::Plants::clover, kindergarten_garden::Plants::grass, kindergarten_garden::Plants::grass}; |
| 17 | + REQUIRE(kindergarten_garden::plants("RC\nGG", "Alice") == expected); |
| 18 | +} |
| 19 | + |
| 20 | +#if defined(EXERCISM_RUN_ALL_TESTS) |
| 21 | + |
| 22 | +TEST_CASE("different garden with single student", "[acd19dc1-2200-4317-bc2a-08f021276b40]") { |
| 23 | + std::array<kindergarten_garden::Plants, 4> expected{kindergarten_garden::Plants::violets, kindergarten_garden::Plants::clover, kindergarten_garden::Plants::radishes, kindergarten_garden::Plants::clover}; |
| 24 | + REQUIRE(kindergarten_garden::plants("VC\nRC", "Alice") == expected); |
| 25 | +} |
| 26 | + |
| 27 | +TEST_CASE("garden with two students", "[c376fcc8-349c-446c-94b0-903947315757]") { |
| 28 | + std::array<kindergarten_garden::Plants, 4> expected{kindergarten_garden::Plants::clover, kindergarten_garden::Plants::grass, kindergarten_garden::Plants::radishes, kindergarten_garden::Plants::clover}; |
| 29 | + REQUIRE(kindergarten_garden::plants("VVCG\nVVRC", "Bob") == expected); |
| 30 | +} |
| 31 | + |
| 32 | +TEST_CASE("second student's garden", "[2d620f45-9617-4924-9d27-751c80d17db9]") { |
| 33 | + std::array<kindergarten_garden::Plants, 4> expected{kindergarten_garden::Plants::clover, kindergarten_garden::Plants::clover, kindergarten_garden::Plants::clover, kindergarten_garden::Plants::clover}; |
| 34 | + REQUIRE(kindergarten_garden::plants("VVCCGG\nVVCCGG", "Bob") == expected); |
| 35 | +} |
| 36 | + |
| 37 | +TEST_CASE("third student's garden", "[57712331-4896-4364-89f8-576421d69c44]") { |
| 38 | + std::array<kindergarten_garden::Plants, 4> expected{kindergarten_garden::Plants::grass, kindergarten_garden::Plants::grass, kindergarten_garden::Plants::grass, kindergarten_garden::Plants::grass}; |
| 39 | + REQUIRE(kindergarten_garden::plants("VVCCGG\nVVCCGG", "Charlie") == expected); |
| 40 | +} |
| 41 | + |
| 42 | +TEST_CASE("for Alice, first student's garden", "[149b4290-58e1-40f2-8ae4-8b87c46e765b]") { |
| 43 | + std::array<kindergarten_garden::Plants, 4> expected{kindergarten_garden::Plants::violets, kindergarten_garden::Plants::radishes, kindergarten_garden::Plants::violets, kindergarten_garden::Plants::radishes}; |
| 44 | + REQUIRE(kindergarten_garden::plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Alice") == expected); |
| 45 | +} |
| 46 | + |
| 47 | +TEST_CASE("for Bob, second student's garden", "[ba25dbbc-10bd-4a37-b18e-f89ecd098a5e]") { |
| 48 | + std::array<kindergarten_garden::Plants, 4> expected{kindergarten_garden::Plants::clover, kindergarten_garden::Plants::grass, kindergarten_garden::Plants::clover, kindergarten_garden::Plants::clover}; |
| 49 | + REQUIRE(kindergarten_garden::plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Bob") == expected); |
| 50 | +} |
| 51 | + |
| 52 | +TEST_CASE("for Charlie", "[566b621b-f18e-4c5f-873e-be30544b838c]") { |
| 53 | + std::array<kindergarten_garden::Plants, 4> expected{kindergarten_garden::Plants::violets, kindergarten_garden::Plants::violets, kindergarten_garden::Plants::clover, kindergarten_garden::Plants::grass}; |
| 54 | + REQUIRE(kindergarten_garden::plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Charlie") == expected); |
| 55 | +} |
| 56 | + |
| 57 | +TEST_CASE("for David", "[3ad3df57-dd98-46fc-9269-1877abf612aa]") { |
| 58 | + std::array<kindergarten_garden::Plants, 4> expected{kindergarten_garden::Plants::radishes, kindergarten_garden::Plants::violets, kindergarten_garden::Plants::clover, kindergarten_garden::Plants::radishes}; |
| 59 | + REQUIRE(kindergarten_garden::plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "David") == expected); |
| 60 | +} |
| 61 | + |
| 62 | +TEST_CASE("for Eve", "[0f0a55d1-9710-46ed-a0eb-399ba8c72db2]") { |
| 63 | + std::array<kindergarten_garden::Plants, 4> expected{kindergarten_garden::Plants::clover, kindergarten_garden::Plants::grass, kindergarten_garden::Plants::radishes, kindergarten_garden::Plants::grass}; |
| 64 | + REQUIRE(kindergarten_garden::plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Eve") == expected); |
| 65 | +} |
| 66 | + |
| 67 | +TEST_CASE("for Fred", "[a7e80c90-b140-4ea1-aee3-f4625365c9a4]") { |
| 68 | + std::array<kindergarten_garden::Plants, 4> expected{kindergarten_garden::Plants::grass, kindergarten_garden::Plants::clover, kindergarten_garden::Plants::violets, kindergarten_garden::Plants::clover}; |
| 69 | + REQUIRE(kindergarten_garden::plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Fred") == expected); |
| 70 | +} |
| 71 | + |
| 72 | +TEST_CASE("for Ginny", "[9d94b273-2933-471b-86e8-dba68694c615]") { |
| 73 | + std::array<kindergarten_garden::Plants, 4> expected{kindergarten_garden::Plants::clover, kindergarten_garden::Plants::grass, kindergarten_garden::Plants::grass, kindergarten_garden::Plants::clover}; |
| 74 | + REQUIRE(kindergarten_garden::plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Ginny") == expected); |
| 75 | +} |
| 76 | + |
| 77 | +TEST_CASE("for Harriet", "[f55bc6c2-ade8-4844-87c4-87196f1b7258]") { |
| 78 | + std::array<kindergarten_garden::Plants, 4> expected{kindergarten_garden::Plants::violets, kindergarten_garden::Plants::radishes, kindergarten_garden::Plants::radishes, kindergarten_garden::Plants::violets}; |
| 79 | + REQUIRE(kindergarten_garden::plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Harriet") == expected); |
| 80 | +} |
| 81 | + |
| 82 | +TEST_CASE("for Ileana", "[759070a3-1bb1-4dd4-be2c-7cce1d7679ae]") { |
| 83 | + std::array<kindergarten_garden::Plants, 4> expected{kindergarten_garden::Plants::grass, kindergarten_garden::Plants::clover, kindergarten_garden::Plants::violets, kindergarten_garden::Plants::clover}; |
| 84 | + REQUIRE(kindergarten_garden::plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Ileana") == expected); |
| 85 | +} |
| 86 | + |
| 87 | +TEST_CASE("for Joseph", "[78578123-2755-4d4a-9c7d-e985b8dda1c6]") { |
| 88 | + std::array<kindergarten_garden::Plants, 4> expected{kindergarten_garden::Plants::violets, kindergarten_garden::Plants::clover, kindergarten_garden::Plants::violets, kindergarten_garden::Plants::grass}; |
| 89 | + REQUIRE(kindergarten_garden::plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Joseph") == expected); |
| 90 | +} |
| 91 | + |
| 92 | +TEST_CASE("for Kincaid, second to last student's garden", "[6bb66df7-f433-41ab-aec2-3ead6e99f65b]") { |
| 93 | + std::array<kindergarten_garden::Plants, 4> expected{kindergarten_garden::Plants::grass, kindergarten_garden::Plants::clover, kindergarten_garden::Plants::clover, kindergarten_garden::Plants::grass}; |
| 94 | + REQUIRE(kindergarten_garden::plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Kincaid") == expected); |
| 95 | +} |
| 96 | + |
| 97 | +TEST_CASE("for Larry, last student's garden", "[d7edec11-6488-418a-94e6-ed509e0fa7eb]") { |
| 98 | + std::array<kindergarten_garden::Plants, 4> expected{kindergarten_garden::Plants::grass, kindergarten_garden::Plants::violets, kindergarten_garden::Plants::clover, kindergarten_garden::Plants::violets}; |
| 99 | + REQUIRE(kindergarten_garden::plants("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", "Larry") == expected); |
| 100 | +} |
| 101 | + |
| 102 | +#endif |
0 commit comments