summaryrefslogtreecommitdiff
path: root/sim/tests/HitPoints.cpp
blob: 5c90b4f9d3a0b6c7952bf38658f50017e119a290 (plain)
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
#include <gtest/gtest.h>

#include <kurator/sim/HitPoints.h>
#include <kurator/universe/ShipType.h>


namespace kurator
{
namespace tests
{


const universe::ShipType SHIP_TYPE {
	"",
	100.0,
	100.0,
	100.0,
	0.0,
	0.5,
	0.2,
	0.5,
};



TEST(HitPoints, Deal)
{
	sim::HitPoints points {SHIP_TYPE};
	EXPECT_TRUE(points.is_alive());
	EXPECT_DOUBLE_EQ(300.0, points.total());
	EXPECT_DOUBLE_EQ(50.0, points.deal(100.0));
	EXPECT_DOUBLE_EQ(250.0, points.total());
	EXPECT_DOUBLE_EQ(50.0 + 80.0, points.deal(200.0));
	EXPECT_DOUBLE_EQ(120.0, points.total());
	EXPECT_DOUBLE_EQ(20.0, points.deal(25.0));
	EXPECT_DOUBLE_EQ(100.0, points.total());
	EXPECT_DOUBLE_EQ(100.0, points.deal(200.0));
	EXPECT_DOUBLE_EQ(0.0, points.total());
	EXPECT_FALSE(points.is_alive());
}


}  // namespace tests
}  // namespace kurator