forked from Neirth/FreeNOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented TestResult class (instead of enum).
This class provides representation of the TestInstance result, including a textual description e.g. in the case an assertion failure.
- Loading branch information
1 parent
f034f59
commit d621503
Showing
7 changed files
with
160 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (C) 2015 Niek Linnenbank | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "TestResult.h" | ||
|
||
TestResult::TestResult(Result result, const char *description) | ||
: m_result(result), m_description(description, true) | ||
{ | ||
} | ||
|
||
bool TestResult::isOK() const | ||
{ | ||
return m_result == Success; | ||
} | ||
|
||
bool TestResult::isFailed() const | ||
{ | ||
return m_result == Failure; | ||
} | ||
|
||
bool TestResult::isSkipped() const | ||
{ | ||
return m_result == Skipped; | ||
} | ||
|
||
const TestResult::Result TestResult::getResult() const | ||
{ | ||
return m_result; | ||
} | ||
|
||
String & TestResult::getDescription() | ||
{ | ||
return m_description; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright (C) 2015 Niek Linnenbank | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef __LIBTEST_TESTRESULT_H | ||
#define __LIBTEST_TESTRESULT_H | ||
|
||
#include <String.h> | ||
|
||
/** | ||
* @group TestResult macros | ||
* @{ | ||
*/ | ||
|
||
#define OK TestResult( TestResult::Success ) | ||
#define FAIL TestResult( TestResult::Failure ) | ||
#define SKIP TestResult( TestResult::Skipped ) | ||
|
||
/** | ||
* @} | ||
*/ | ||
|
||
/** | ||
* Represents a Test result created by a TestInstance. | ||
*/ | ||
class TestResult | ||
{ | ||
public: | ||
|
||
/** | ||
* Result codes. | ||
*/ | ||
enum Result | ||
{ | ||
Success, | ||
Failure, | ||
Skipped | ||
}; | ||
|
||
/** | ||
* Constructor | ||
*/ | ||
TestResult(Result result, const char *description = ""); | ||
|
||
/** | ||
* Check if the test passed. | ||
*/ | ||
bool isOK() const; | ||
|
||
/** | ||
* Check if the test failed. | ||
*/ | ||
bool isFailed() const; | ||
|
||
/** | ||
* Check if the test is skipped. | ||
*/ | ||
bool isSkipped() const; | ||
|
||
/** | ||
* Get result code. | ||
*/ | ||
const Result getResult() const; | ||
|
||
/** | ||
* Get result description. | ||
*/ | ||
String & getDescription(); | ||
|
||
private: | ||
|
||
/** The result code for this test. */ | ||
const Result m_result; | ||
|
||
/** Text describing the result. */ | ||
String m_description; | ||
}; | ||
|
||
#endif /* __LIBTEST_TESTRESULT_H */ |