VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
TestQueueImp.cpp
Go to the documentation of this file.
1//=======================================================================================
2// ____ ____ __ ______ __________ __ __ __ __
3// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
4// \ \ | | | | | |_) | | | | | | | / \ | |
5// \ \ | | | | | _ / | | | | | | / /\ \ | |
6// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
7// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
8// \ \ | | ________________________________________________________________
9// \ \ | | | ______________________________________________________________|
10// \ \| | | | __ __ __ __ ______ _______
11// \ | | |_____ | | | | | | | | | _ \ / _____)
12// \ | | _____| | | | | | | | | | | \ \ \_______
13// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
14// \ _____| |__| |________| \_______/ |__| |______/ (_______/
15//
16// This file is part of VirtualFluids. VirtualFluids is free software: you can
17// redistribute it and/or modify it under the terms of the GNU General Public
18// License as published by the Free Software Foundation, either version 3 of
19// the License, or (at your option) any later version.
20//
21// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT
22// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24// for more details.
25//
26// SPDX-License-Identifier: GPL-3.0-or-later
27// SPDX-FileCopyrightText: Copyright © VirtualFluids Project contributors, see AUTHORS.md in root folder
28//
32//=======================================================================================
33#include "TestQueueImp.h"
34#include <algorithm>
35
37#include "Utilities/Test/Test.h"
38
39#include <basics/DataTypes.h>
40
42{
43 for (const auto& test : tests)
44 test->run();
45
47
48 return TestSuiteResult(std::clamp(numberOfFailedTest, 0, 1));
49}
50
52{
53 calcTestNumbers();
54 colorOutput->makeFinalTestOutputHead(numberOfTests, numberOfExecutedTest, numberOfPassedTest, numberOfFailedTest,
55 numberOfErrorTest, numberOfNotExecutedTest);
56 for (uint i = 0; i < tests.size(); i++)
57 tests.at(i)->makeConsoleOutput();
58 colorOutput->makeFinalTestOutputFoot(numberOfTests, numberOfExecutedTest, numberOfPassedTest, numberOfFailedTest,
59 numberOfErrorTest, numberOfNotExecutedTest);
60}
61
63{
64 return numberOfFailedTest;
65}
66
67std::shared_ptr<TestQueueImp> TestQueueImp::getNewInstance(std::shared_ptr<ColorConsoleOutput> colorOutput)
68{
69 return std::shared_ptr<TestQueueImp>(new TestQueueImp(colorOutput));
70}
71
72void TestQueueImp::addTest(std::shared_ptr<Test> test)
73{
74 tests.push_back(test);
75}
76
77TestQueueImp::TestQueueImp(std::shared_ptr<ColorConsoleOutput> colorOutput) : colorOutput(colorOutput)
78{
79 tests.resize(0);
80}
81
82void TestQueueImp::calcTestNumbers()
83{
84 numberOfTests = tests.size();
85 numberOfExecutedTest = 0;
86 numberOfPassedTest = 0;
87 numberOfFailedTest = 0;
88 numberOfErrorTest = 0;
89 numberOfNotExecutedTest = 0;
90
91 for (uint i = 0; i < tests.size(); i++) {
92 switch (tests.at(i)->getTestStatus()) {
93 case passed:
94 numberOfPassedTest++;
95 numberOfExecutedTest++;
96 break;
97 case failed:
98 numberOfFailedTest++;
99 numberOfExecutedTest++;
100 break;
101 case test_error:
102 numberOfErrorTest++;
103 break;
105 numberOfNotExecutedTest++;
106 break;
107 default:
108 break;
109 }
110 }
111}
112
int getNumberOfFailedTests() const noexcept override
TestSuiteResult
Definition TestQueue.h:36
void makeFinalOutput() override
TestSuiteResult run() override
void addTest(std::shared_ptr< Test > test)
static std::shared_ptr< TestQueueImp > getNewInstance(std::shared_ptr< ColorConsoleOutput > colorOutput)
@ test_error
Definition TestStatus.h:36
@ simulationCrashed
Definition TestStatus.h:36
@ failed
Definition TestStatus.h:36
@ passed
Definition TestStatus.h:36
std::shared_ptr< T > SPtr
unsigned int uint
Definition DataTypes.h:47