diff options
author | Aki <please@ignore.pl> | 2023-02-05 01:18:18 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2023-02-05 01:18:18 +0100 |
commit | 7c8aac19374013e7366b5afbf5d85fe151de3669 (patch) | |
tree | a447bf2c9366eb222ca37e29f679c84a166a4d18 /sim/tests | |
parent | dedd9566a53de73215a13117e2704e8df4d04e95 (diff) | |
download | kurator-7c8aac19374013e7366b5afbf5d85fe151de3669.zip kurator-7c8aac19374013e7366b5afbf5d85fe151de3669.tar.gz kurator-7c8aac19374013e7366b5afbf5d85fe151de3669.tar.bz2 |
Added simple test for HitPoints
This should have been added earlier. The test itself is questionable
and overall very optimistic about the edge cases. The intent of this
commit is purely set up of the testing framework.
Diffstat (limited to 'sim/tests')
-rw-r--r-- | sim/tests/HitPoints.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/sim/tests/HitPoints.cpp b/sim/tests/HitPoints.cpp new file mode 100644 index 0000000..8b8ef84 --- /dev/null +++ b/sim/tests/HitPoints.cpp @@ -0,0 +1,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, points.deal(100.0)); + EXPECT_DOUBLE_EQ(200.0, points.total()); + EXPECT_DOUBLE_EQ(100.0, points.deal(125.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 |