-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFoodtest.cpp
More file actions
101 lines (77 loc) · 2.87 KB
/
Foodtest.cpp
File metadata and controls
101 lines (77 loc) · 2.87 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include "gtest/gtest.h"
#include "food.h"
#include "foodmap.h"
#include "antsimutils.h"
class FoodMapSpy: public FoodMap
{
public:
int get_amount_of_extra_food()
{
return amountOfExtraFood;
}
protected:
};
class FoodSpy: public Food
{
public:
FoodSpy()
{
initialFoodStrength = foodStrength;
}
int get_initial_food_strength()
{
return initialFoodStrength;
}
void set_strength(int strength)
{
foodStrength = strength;
}
protected:
int initialFoodStrength{0};
};
TEST(FoodMapTest, GivenAFoodMap_WhenCheckingToSeeIfItHasFoodOnIt_ExpectListSizeToEqualAmountOfFoodTimesExtraFood)
{
FoodMapSpy testingFoodMap;
int amountOfFood{10};
testingFoodMap.populate_food(amountOfFood);
int foodMapSize{static_cast<int>(testingFoodMap.get_food().size())};
EXPECT_EQ(amountOfFood * testingFoodMap.get_amount_of_extra_food() , foodMapSize);
}
TEST(FoodTest, GivenAFood_WhenCheckingToSeeIfItDecrementsStrength_ExpectItsStrengthToDecreaseByOne)
{
FoodSpy testingFood;
EXPECT_TRUE(testingFood.get_strength() == testingFood.get_initial_food_strength());
testingFood.decrement_food();
EXPECT_TRUE(testingFood.get_strength() == testingFood.get_initial_food_strength() - 1);
}
TEST(FoodTest, GivenAFood_WhenCheckingToSeeIfTheFoodPositionIsRandom_ExpectFoodPositionToBeRandom)
{
FoodSpy testingFoodOne;
EXPECT_TRUE(testingFoodOne.get_x_coordinate() != testingFoodOne.get_y_coordinate());
FoodSpy testingFoodTwo;
EXPECT_TRUE(testingFoodTwo.get_x_coordinate() != testingFoodTwo.get_y_coordinate());
EXPECT_TRUE(testingFoodOne.get_x_coordinate() != testingFoodTwo.get_x_coordinate());
EXPECT_TRUE(testingFoodOne.get_y_coordinate() != testingFoodTwo.get_y_coordinate());
}
TEST(FoodMapTest, GivenAFoodMap_WhenDeletingEmpltyFoods_CheckToSeeIfEmptyFoodDeletesFromFoodMapVector)
{
EXPECT_TRUE(false);//ILL NEED POINTERS FOR THIS
}
TEST(SearchTest, WhenGivenTwoPointsNearOneAnother_WhenCheckingToSeeIfCheckingFunctionReturnsTrue_ExpectFunctionToReturnTrue)
{
EXPECT_TRUE(check_two_points(2.0,5.0,1.0,6.0,4.0));
}
TEST(SearchTest, WhenGivenTwoPointNearOneAnotherInVectors_WhenCheckingToSeeIfCheckingFunctionReturnsTrue_ExpectFunctionToReturnTrue)
{
Eigen::Vector2d firstVector{{1.0,1.0}};
Eigen::Vector2d secondVector{{2.0,2.0}};
int tolerance{4};
EXPECT_TRUE(are_these_points_near_eachother(firstVector,secondVector,tolerance));
}
TEST(SearchTest, WhenGivenTwoPointNearOneAnotherOneInVectorAndTheOtherPointAsASingleValue_WhenCheckingToSeeIfCheckingFunctionReturnsTrue_ExpectFunctionToReturnTrue)
{
Eigen::Vector2d firstVector{{1.0,1.0}};
double singleValue{1.0};
int tolerance{4};
EXPECT_TRUE(are_these_points_near_eachother(firstVector,singleValue,tolerance));
}