Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#include "Test.h"
UnitTest :: UnitTest()
: passed(true)
{
}
UnitTest :: ~UnitTest()
{
}
void UnitTest :: TestIntro()
{
std::cout << "UNIT TEST ===> " << testName << std::endl;
}
void UnitTest :: TestConclusion()
{
std::cout << "TEST: " << testName << " " << (passed ? "PASSED" : "FAILED") << std::endl << std::endl;
}
bool UnitTest :: Passed()
{
return passed;
}
// UnitTest protected Methods
void UnitTest :: Fail()
{
passed = false;
}
void UnitTest :: AssertTrue(bool expression)
{
if (!expression) { Fail(); }
}
void UnitTest :: AssertFalse(bool expression)
{
if (expression) { Fail(); }
}
// ComponentTest class
ComponentTest :: ComponentTest()
: run(0), failed(0), passed(0)
{
}
ComponentTest :: ~ComponentTest()
{
for (UnitTest *test : tests) {
delete test;
}
tests.clear();
}
void ComponentTest :: PrintIntro()
{
std::cout << "========================================================================" << std::endl;
std::cout << "Testing: " << testName << std::endl;
std::cout << "========================================================================" << std::endl << std::endl;
}
void ComponentTest :: PrintConclusion()
{
std::cout << "========================================================================" << std::endl;
std::cout << "Completed Testing: " << testName << std::endl;
std::cout << "========================================================================" << std::endl << std::endl;
}
bool ComponentTest :: TestComponent()
{
PrintIntro();
for (UnitTest *test : tests) {
++run;
test->TestIntro();
test->PerformTest();
test->Passed() ? ++passed : ++failed;
test->TestConclusion();
}
PrintConclusion();
return GetTestsFailed() == 0;
}
unsigned long long ComponentTest :: GetTestCount()
{
return run;
}
unsigned long long ComponentTest :: GetTestsFailed()
{
return failed;
}
unsigned long long ComponentTest :: GetTestsPassed()
{
return passed;
}