blob: 44729b36929b2dd53ec5a26e49b266b58c808096 (
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
|
#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(std::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();
}
|