Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/test/game_tests_main.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-06-20 14:33:09 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-06-20 14:33:09 +1000
commit6352e8e3196f78388b6c771073f9e03eaa612673 (patch)
treee23772f79a7fbc41bc9108951e9e136857484bf4 /source/test/game_tests_main.cpp
parent6741a057e5639280d85d0f88ba26f000baa58f61 (diff)
everything everywhere
all at once
Diffstat (limited to 'source/test/game_tests_main.cpp')
-rw-r--r--source/test/game_tests_main.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/source/test/game_tests_main.cpp b/source/test/game_tests_main.cpp
new file mode 100644
index 0000000..4cfb714
--- /dev/null
+++ b/source/test/game_tests_main.cpp
@@ -0,0 +1,43 @@
+#include "StarLogging.hpp"
+#include "StarFile.hpp"
+#include "StarRootLoader.hpp"
+
+#include "gtest/gtest.h"
+
+using namespace Star;
+
+struct ErrorLogSink : public LogSink {
+ ErrorLogSink() {
+ setLevel(LogLevel::Error);
+ }
+
+ void log(char const* msg, LogLevel) override {
+ ADD_FAILURE() << "Error was logged: " << msg;
+ }
+};
+
+class TestEnvironment : public testing::Environment {
+public:
+ unique_ptr<Root> root;
+ Root::Settings settings;
+
+ TestEnvironment(Root::Settings settings)
+ : settings(move(settings)) {}
+
+ virtual void SetUp() {
+ Logger::addSink(make_shared<ErrorLogSink>());
+ root = make_unique<Root>(settings);
+ root->configuration()->set("clearUniverseFiles", true);
+ root->configuration()->set("clearPlayerFiles", true);
+ }
+
+ virtual void TearDown() {
+ root.reset();
+ }
+};
+
+GTEST_API_ int main(int argc, char** argv) {
+ testing::InitGoogleTest(&argc, argv);
+ testing::AddGlobalTestEnvironment(new TestEnvironment(RootLoader({{}, {}, {}, LogLevel::Error, true, {}}).commandParseOrDie(argc, argv).first));
+ return RUN_ALL_TESTS();
+}