aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/testing.cpp
blob: 54d89ded29febaa6b5bf1bdd6d2adb2b29239c9f (plain) (blame)
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
45
46
47
48
49
50
51
52
53
54
// Copyright Epic Games, Inc. All Rights Reserved.

#include "zencore/testing.h"
#include "zencore/logging.h"

#if ZEN_WITH_TESTS

namespace zen::testing {

using namespace std::literals;

struct TestRunner::Impl
{
	doctest::Context Session;
};

TestRunner::TestRunner()
{
	m_Impl = std::make_unique<Impl>();
}

TestRunner::~TestRunner()
{
}

int
TestRunner::ApplyCommandLine(int argc, char const* const* argv)
{
	m_Impl->Session.applyCommandLine(argc, argv);

	for (int i = 1; i < argc; ++i)
	{
		if (argv[i] == "--debug"sv)
		{
			zen::logging::SetLogLevel(zen::logging::level::Debug);
		}
		else if (argv[i] == "--verbose"sv)
		{
			zen::logging::SetLogLevel(zen::logging::level::Trace);
		}
	}

	return 0;
}

int
TestRunner::Run()
{
	return m_Impl->Session.run();
}

}  // namespace zen::testing

#endif	// ZEN_WITH_TESTS