|
8 | 8 | #include "Road.h" |
9 | 9 | #include "Util.h" |
10 | 10 |
|
11 | | -TEST(road_constructor_1){ |
| 11 | +TEST(road_constructor_good){ |
12 | 12 | Coordinate start = Coordinate(0,0); |
13 | 13 | Coordinate end = Coordinate(0,1); |
| 14 | + Player test_player("tester"); |
| 15 | + Road test_road(start, end, test_player); |
| 16 | + |
| 17 | + CHECK(test_road.start == start); |
| 18 | + CHECK(test_road.end == end); |
| 19 | +} |
| 20 | + |
| 21 | +TEST(road_constuctor_bad){ |
| 22 | + Coordinate start = Coordinate(0,0); |
| 23 | + Coordinate end = Coordinate(3,4); |
| 24 | + |
| 25 | + Player test_player("tester"); |
| 26 | + //test start == end |
| 27 | + try { |
| 28 | + Road test_road_1(start, start, test_player); |
| 29 | + CHECK(false); |
| 30 | + } catch (int n) { |
| 31 | + CHECK(n == -1); |
| 32 | + } |
| 33 | + //test road too long |
| 34 | + try { |
| 35 | + Road test_road_2(start, end, test_player); |
| 36 | + CHECK(false); |
| 37 | + } catch (int n) { |
| 38 | + CHECK(n == -1); |
| 39 | + } |
| 40 | + |
| 41 | +} |
| 42 | + |
| 43 | +TEST(road_equals_Road){ |
| 44 | + Coordinate start_1 = Coordinate(0,0); |
| 45 | + Coordinate end_1 = Coordinate(0,1); |
| 46 | + Player test_player_1("tester_1"); |
| 47 | + Road test_road_1(start_1, end_1, test_player_1); |
| 48 | + |
| 49 | + |
| 50 | + Coordinate start_2 = Coordinate(0,1); |
| 51 | + Coordinate end_2 = Coordinate(0,0); |
| 52 | + Player test_player_2("tester_2"); |
| 53 | + Road test_road_2(start_2, end_2, test_player_2); |
| 54 | + |
| 55 | + Coordinate start_3 = Coordinate(1,1); |
| 56 | + Coordinate end_3 = Coordinate(1,2); |
| 57 | + Player test_player_3("tester_3"); |
| 58 | + Road test_road_3(start_3, end_3, test_player_3); |
| 59 | + |
| 60 | + CHECK(test_road_1.equals(test_road_2)); |
| 61 | + CHECK(!test_road_1.equals(test_road_3)); |
| 62 | +} |
| 63 | + |
| 64 | +TEST(road_equals_Coordinate){ |
| 65 | + Coordinate start_1 = Coordinate(0,0); |
| 66 | + Coordinate end_1 = Coordinate(0,1); |
| 67 | + Player test_player_1("tester_1"); |
| 68 | + Road test_road_1(start_1, end_1, test_player_1); |
| 69 | + |
| 70 | + |
| 71 | + Coordinate start_2 = Coordinate(0,1); |
| 72 | + Coordinate end_2 = Coordinate(0,0); |
| 73 | + |
| 74 | + Coordinate start_3 = Coordinate(1,1); |
| 75 | + Coordinate end_3 = Coordinate(1,2); |
| 76 | + |
| 77 | + CHECK(test_road_1.equals(start_2, end_2)); |
| 78 | + CHECK(!test_road_1.equals(start_3, end_3)); |
14 | 79 | } |
15 | 80 |
|
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | + |
0 commit comments