1 | //************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// |
2 | //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// |
3 | #include "Testing/BsTestSuite.h" |
4 | #include "Testing/BsTestOutput.h" |
5 | |
6 | namespace bs |
7 | { |
8 | TestSuite::TestEntry::TestEntry(Func test, const String& name) |
9 | :test(test), name(name) |
10 | { } |
11 | |
12 | void TestSuite::run(TestOutput& output) |
13 | { |
14 | mOutput = &output; |
15 | |
16 | startUp(); |
17 | |
18 | for (auto& testEntry : mTests) |
19 | { |
20 | mActiveTestName = testEntry.name; |
21 | |
22 | (this->*(testEntry.test))(); |
23 | } |
24 | |
25 | for (auto& suite : mSuites) |
26 | { |
27 | suite->run(output); |
28 | } |
29 | |
30 | shutDown(); |
31 | } |
32 | |
33 | void TestSuite::add(const SPtr<TestSuite>& suite) |
34 | { |
35 | mSuites.push_back(suite); |
36 | } |
37 | |
38 | void TestSuite::addTest(Func test, const String& name) |
39 | { |
40 | mTests.push_back(TestEntry(test, name)); |
41 | } |
42 | |
43 | void TestSuite::assertment(bool success, const String& desc, const String& file, long line) |
44 | { |
45 | if (!success) |
46 | mOutput->outputFail(desc, mActiveTestName, file, line); |
47 | } |
48 | } |
49 | |