summaryrefslogtreecommitdiffhomepage
path: root/StarsEx/test
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2024-04-03 01:31:01 +0200
committerAki <please@ignore.pl>2024-04-03 01:31:01 +0200
commite0f9f411056c235947b809cb21c477aa5acca1b4 (patch)
tree1371e376659d66ec0c881032b6001630aa4f964b /StarsEx/test
parent7f1e5f578ec184ebcbbdcd9f7725619ea426d5e4 (diff)
downloadstarshatter-e0f9f411056c235947b809cb21c477aa5acca1b4.zip
starshatter-e0f9f411056c235947b809cb21c477aa5acca1b4.tar.gz
starshatter-e0f9f411056c235947b809cb21c477aa5acca1b4.tar.bz2
Fixed mission points reward calculation
Diffstat (limited to 'StarsEx/test')
-rw-r--r--StarsEx/test/ShipStats.cpp29
-rw-r--r--StarsEx/test/dump_missions.cpp1
2 files changed, 30 insertions, 0 deletions
diff --git a/StarsEx/test/ShipStats.cpp b/StarsEx/test/ShipStats.cpp
new file mode 100644
index 0000000..1430573
--- /dev/null
+++ b/StarsEx/test/ShipStats.cpp
@@ -0,0 +1,29 @@
+#include <gtest/gtest.h>
+
+#include <Clock.h>
+#include <SimEvent.h>
+
+
+TEST(StarsEx, EffectivePoints)
+{
+ Clock::Init();
+ ShipStats::Initialize();
+ auto* first = ShipStats::Find("first");
+ ASSERT_NE(nullptr, first);
+ EXPECT_EQ(0, first->EffectivePoints());
+ first->SetFlightTime(590.0l);
+ EXPECT_EQ(0, first->EffectivePoints());
+ first->SetFlightTime(610.0l);
+ EXPECT_EQ(10, first->EffectivePoints());
+ first->SetFlightTime(1210.0l);
+ EXPECT_EQ(20, first->EffectivePoints());
+ const auto* destroyed = first->AddEvent(SimEvent::DESTROYED);
+ first->Summarize();
+ EXPECT_EQ(0, first->EffectivePoints());
+ auto* second = ShipStats::Find("second");
+ ASSERT_NE(nullptr, second);
+ const auto* docked = second->AddEvent(SimEvent::DOCK);
+ EXPECT_EQ(100, second->EffectivePoints());
+ ShipStats::Close();
+ Clock::Close();
+}
diff --git a/StarsEx/test/dump_missions.cpp b/StarsEx/test/dump_missions.cpp
new file mode 100644
index 0000000..a0e5ffc
--- /dev/null
+++ b/StarsEx/test/dump_missions.cpp
@@ -0,0 +1 @@
+int dump_missions = 0;