|
| 1 | +const std = @import("std"); |
| 2 | +const testing = std.testing; |
| 3 | + |
| 4 | +const kindergarten_garden = @import("kindergarten_garden.zig"); |
| 5 | + |
| 6 | +test "partial garden with single student" { |
| 7 | + const diagram: []const u8 = |
| 8 | + \\RC |
| 9 | + \\GG |
| 10 | + ; |
| 11 | + const expected = .{ .radishes, .clover, .grass, .grass }; |
| 12 | + const actual = kindergarten_garden.plants(diagram, "Alice"); |
| 13 | + try testing.expectEqual(expected, actual); |
| 14 | +} |
| 15 | + |
| 16 | +test "partial garden-different garden with single student" { |
| 17 | + const diagram: []const u8 = |
| 18 | + \\VC |
| 19 | + \\RC |
| 20 | + ; |
| 21 | + const expected = .{ .violets, .clover, .radishes, .clover }; |
| 22 | + const actual = kindergarten_garden.plants(diagram, "Alice"); |
| 23 | + try testing.expectEqual(expected, actual); |
| 24 | +} |
| 25 | + |
| 26 | +test "partial garden with two students" { |
| 27 | + const diagram: []const u8 = |
| 28 | + \\VVCG |
| 29 | + \\VVRC |
| 30 | + ; |
| 31 | + const expected = .{ .clover, .grass, .radishes, .clover }; |
| 32 | + const actual = kindergarten_garden.plants(diagram, "Bob"); |
| 33 | + try testing.expectEqual(expected, actual); |
| 34 | +} |
| 35 | + |
| 36 | +test "partial garden-multiple students for the same garden with three students-second student's garden" { |
| 37 | + const diagram: []const u8 = |
| 38 | + \\VVCCGG |
| 39 | + \\VVCCGG |
| 40 | + ; |
| 41 | + const expected = .{ .clover, .clover, .clover, .clover }; |
| 42 | + const actual = kindergarten_garden.plants(diagram, "Bob"); |
| 43 | + try testing.expectEqual(expected, actual); |
| 44 | +} |
| 45 | + |
| 46 | +test "partial garden-multiple students for the same garden with three students-third student's garden" { |
| 47 | + const diagram: []const u8 = |
| 48 | + \\VVCCGG |
| 49 | + \\VVCCGG |
| 50 | + ; |
| 51 | + const expected = .{ .grass, .grass, .grass, .grass }; |
| 52 | + const actual = kindergarten_garden.plants(diagram, "Charlie"); |
| 53 | + try testing.expectEqual(expected, actual); |
| 54 | +} |
| 55 | + |
| 56 | +test "full garden-for Alice, first student's garden" { |
| 57 | + const diagram: []const u8 = |
| 58 | + \\VRCGVVRVCGGCCGVRGCVCGCGV |
| 59 | + \\VRCCCGCRRGVCGCRVVCVGCGCV |
| 60 | + ; |
| 61 | + const expected = .{ .violets, .radishes, .violets, .radishes }; |
| 62 | + const actual = kindergarten_garden.plants(diagram, "Alice"); |
| 63 | + try testing.expectEqual(expected, actual); |
| 64 | +} |
| 65 | + |
| 66 | +test "full garden-for Bob, second student's garden" { |
| 67 | + const diagram: []const u8 = |
| 68 | + \\VRCGVVRVCGGCCGVRGCVCGCGV |
| 69 | + \\VRCCCGCRRGVCGCRVVCVGCGCV |
| 70 | + ; |
| 71 | + const expected = .{ .clover, .grass, .clover, .clover }; |
| 72 | + const actual = kindergarten_garden.plants(diagram, "Bob"); |
| 73 | + try testing.expectEqual(expected, actual); |
| 74 | +} |
| 75 | + |
| 76 | +test "full garden-for Charlie" { |
| 77 | + const diagram: []const u8 = |
| 78 | + \\VRCGVVRVCGGCCGVRGCVCGCGV |
| 79 | + \\VRCCCGCRRGVCGCRVVCVGCGCV |
| 80 | + ; |
| 81 | + const expected = .{ .violets, .violets, .clover, .grass }; |
| 82 | + const actual = kindergarten_garden.plants(diagram, "Charlie"); |
| 83 | + try testing.expectEqual(expected, actual); |
| 84 | +} |
| 85 | + |
| 86 | +test "full garden-for David" { |
| 87 | + const diagram: []const u8 = |
| 88 | + \\VRCGVVRVCGGCCGVRGCVCGCGV |
| 89 | + \\VRCCCGCRRGVCGCRVVCVGCGCV |
| 90 | + ; |
| 91 | + const expected = .{ .radishes, .violets, .clover, .radishes }; |
| 92 | + const actual = kindergarten_garden.plants(diagram, "David"); |
| 93 | + try testing.expectEqual(expected, actual); |
| 94 | +} |
| 95 | + |
| 96 | +test "full garden-for Eve" { |
| 97 | + const diagram: []const u8 = |
| 98 | + \\VRCGVVRVCGGCCGVRGCVCGCGV |
| 99 | + \\VRCCCGCRRGVCGCRVVCVGCGCV |
| 100 | + ; |
| 101 | + const expected = .{ .clover, .grass, .radishes, .grass }; |
| 102 | + const actual = kindergarten_garden.plants(diagram, "Eve"); |
| 103 | + try testing.expectEqual(expected, actual); |
| 104 | +} |
| 105 | + |
| 106 | +test "full garden-for Fred" { |
| 107 | + const diagram: []const u8 = |
| 108 | + \\VRCGVVRVCGGCCGVRGCVCGCGV |
| 109 | + \\VRCCCGCRRGVCGCRVVCVGCGCV |
| 110 | + ; |
| 111 | + const expected = .{ .grass, .clover, .violets, .clover }; |
| 112 | + const actual = kindergarten_garden.plants(diagram, "Fred"); |
| 113 | + try testing.expectEqual(expected, actual); |
| 114 | +} |
| 115 | + |
| 116 | +test "full garden-for Ginny" { |
| 117 | + const diagram: []const u8 = |
| 118 | + \\VRCGVVRVCGGCCGVRGCVCGCGV |
| 119 | + \\VRCCCGCRRGVCGCRVVCVGCGCV |
| 120 | + ; |
| 121 | + const expected = .{ .clover, .grass, .grass, .clover }; |
| 122 | + const actual = kindergarten_garden.plants(diagram, "Ginny"); |
| 123 | + try testing.expectEqual(expected, actual); |
| 124 | +} |
| 125 | + |
| 126 | +test "full garden-for Harriet" { |
| 127 | + const diagram: []const u8 = |
| 128 | + \\VRCGVVRVCGGCCGVRGCVCGCGV |
| 129 | + \\VRCCCGCRRGVCGCRVVCVGCGCV |
| 130 | + ; |
| 131 | + const expected = .{ .violets, .radishes, .radishes, .violets }; |
| 132 | + const actual = kindergarten_garden.plants(diagram, "Harriet"); |
| 133 | + try testing.expectEqual(expected, actual); |
| 134 | +} |
| 135 | + |
| 136 | +test "full garden-for Ileana" { |
| 137 | + const diagram: []const u8 = |
| 138 | + \\VRCGVVRVCGGCCGVRGCVCGCGV |
| 139 | + \\VRCCCGCRRGVCGCRVVCVGCGCV |
| 140 | + ; |
| 141 | + const expected = .{ .grass, .clover, .violets, .clover }; |
| 142 | + const actual = kindergarten_garden.plants(diagram, "Ileana"); |
| 143 | + try testing.expectEqual(expected, actual); |
| 144 | +} |
| 145 | + |
| 146 | +test "full garden-for Joseph" { |
| 147 | + const diagram: []const u8 = |
| 148 | + \\VRCGVVRVCGGCCGVRGCVCGCGV |
| 149 | + \\VRCCCGCRRGVCGCRVVCVGCGCV |
| 150 | + ; |
| 151 | + const expected = .{ .violets, .clover, .violets, .grass }; |
| 152 | + const actual = kindergarten_garden.plants(diagram, "Joseph"); |
| 153 | + try testing.expectEqual(expected, actual); |
| 154 | +} |
| 155 | + |
| 156 | +test "full garden-for Kincaid, second to last student's garden" { |
| 157 | + const diagram: []const u8 = |
| 158 | + \\VRCGVVRVCGGCCGVRGCVCGCGV |
| 159 | + \\VRCCCGCRRGVCGCRVVCVGCGCV |
| 160 | + ; |
| 161 | + const expected = .{ .grass, .clover, .clover, .grass }; |
| 162 | + const actual = kindergarten_garden.plants(diagram, "Kincaid"); |
| 163 | + try testing.expectEqual(expected, actual); |
| 164 | +} |
| 165 | + |
| 166 | +test "full garden-for Larry, last student's garden" { |
| 167 | + const diagram: []const u8 = |
| 168 | + \\VRCGVVRVCGGCCGVRGCVCGCGV |
| 169 | + \\VRCCCGCRRGVCGCRVVCVGCGCV |
| 170 | + ; |
| 171 | + const expected = .{ .grass, .violets, .clover, .violets }; |
| 172 | + const actual = kindergarten_garden.plants(diagram, "Larry"); |
| 173 | + try testing.expectEqual(expected, actual); |
| 174 | +} |
0 commit comments