The Sparta Modeling Framework
|
File that defines the SpartaTester class and testing Macros. More...
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstring>
#include <inttypes.h>
#include <stdexcept>
#include <string>
#include <set>
#include <boost/algorithm/string/predicate.hpp>
#include "sparta/utils/Colors.hpp"
#include "simdb/utils/MathUtils.hpp"
Go to the source code of this file.
Classes | |
class | sparta::SpartaTester |
A simple testing class. More... | |
Namespaces | |
namespace | sparta |
Macros for handling exponential backoff. | |
Macros | |
#define | TEST_INIT |
Initialized the test. Should be placed OUTSIDE of a code block SOMEWHERE in the test source. | |
#define | EXPECT_REACHED() sparta::SpartaTester::getInstance()->reachedMethod(__FUNCTION__) |
Add this method to be checked against whether or not it was called at least once. This macro can be placed anywhere inside the function expected to be called. | |
#define | ENSURE_ALL_REACHED(x) sparta::SpartaTester::getInstance()->expectAllReached(x, __LINE__, __FUNCTION__) |
make sure that the same number of methods were reached as were expected by this test. | |
#define | EXPECT_TRUE(x) sparta::SpartaTester::getInstance()->expect((x), #x, __LINE__, __FILE__) |
Determine if the block x evaluates to true. | |
#define | EXPECT_EQUAL(x, y) sparta::SpartaTester::getInstance()->expectEqual((x), (y), true, #x, __LINE__, __FILE__) |
Determine if the block x is equal (using operator= on x) to y. | |
#define | EXPECT_NOTEQUAL(x, y) sparta::SpartaTester::getInstance()->expectEqual((x), (y), false, #x, __LINE__, __FILE__) |
Determine if the block x is not equal (using operator= on x) to y. | |
#define | EXPECT_WITHIN_TOLERANCE(x, y, tol) |
Determine if the block x is equal (using operator= on x) to y within a specified tolerance. | |
#define | EXPECT_WITHIN_EPSILON(x, y) |
Determine if the block x is equal (using operator= on x) to y within 2x the machine epsilon, as determined by std::numeric_limits<T>::epsilon() | |
#define | EXPECT_FALSE(x) sparta::SpartaTester::getInstance()->expect(!(x), #x, __LINE__, __FILE__) |
Determine if the block x evaluates to false. | |
#define | EXPECT_THROW(x) |
Determine if the block x correctly throws an exception. | |
#define | EXPECT_THROW_MSG_SHORT(x, expected_msg) |
Determine if the block x correctly throws an exception with the given message (no line number/file) | |
#define | EXPECT_THROW_MSG_LONG(x, expected_msg) |
Determine if the block x correctly throws an exception with the given message on the file and line number. | |
#define | EXPECT_THROW_MSG_CONTAINS(x, expected_msg) |
#define | EXPECT_NOTHROW(x) |
Determine if the block x throws an exception incorrectly. | |
#define | EXPECT_FILES_EQUAL(a, b) |
Determine if the block a and b contain the same exact data with the exception of lines beginning with '#'. | |
#define | EXPECT_FILES_NOTEQUAL(a, b) |
Determine if the block a and b contain different data with the exception of lines beginning with '#'. | |
#define | ERROR_CODE sparta::SpartaTester::getErrorCode() |
The number of errors found in the testing. | |
#define | REPORT_ERROR |
Prints the error code with a nice pretty message. | |
File that defines the SpartaTester class and testing Macros.
Definition in file SpartaTester.hpp.
#define ENSURE_ALL_REACHED | ( | x | ) | sparta::SpartaTester::getInstance()->expectAllReached(x, __LINE__, __FUNCTION__) |
make sure that the same number of methods were reached as were expected by this test.
x | the number of unique methods that you expect to be reached at least once. x should equal the number of times EXPECT_REACHED() is placed throughout the test. |
Definition at line 429 of file SpartaTester.hpp.
#define ERROR_CODE sparta::SpartaTester::getErrorCode() |
The number of errors found in the testing.
Definition at line 714 of file SpartaTester.hpp.
#define EXPECT_EQUAL | ( | x, | |
y | |||
) | sparta::SpartaTester::getInstance()->expectEqual((x), (y), true, #x, __LINE__, __FILE__) |
Determine if the block x is equal (using operator= on x) to y.
Value of x and y, if not equal, is printed in error message.
Example usage:
Definition at line 466 of file SpartaTester.hpp.
#define EXPECT_FALSE | ( | x | ) | sparta::SpartaTester::getInstance()->expect(!(x), #x, __LINE__, __FILE__) |
Determine if the block x evaluates to false.
Example usage:
Definition at line 550 of file SpartaTester.hpp.
#define EXPECT_FILES_EQUAL | ( | a, | |
b | |||
) |
Determine if the block a and b contain the same exact data with the exception of lines beginning with '#'.
Example usage:
Definition at line 692 of file SpartaTester.hpp.
#define EXPECT_FILES_NOTEQUAL | ( | a, | |
b | |||
) |
Determine if the block a and b contain different data with the exception of lines beginning with '#'.
Example usage:
Definition at line 706 of file SpartaTester.hpp.
#define EXPECT_NOTEQUAL | ( | x, | |
y | |||
) | sparta::SpartaTester::getInstance()->expectEqual((x), (y), false, #x, __LINE__, __FILE__) |
Determine if the block x is not equal (using operator= on x) to y.
Value of x and y, if equal, is printed in error message.
Example usage:
Definition at line 486 of file SpartaTester.hpp.
#define EXPECT_NOTHROW | ( | x | ) |
Determine if the block x throws an exception incorrectly.
Example usage:
Definition at line 667 of file SpartaTester.hpp.
#define EXPECT_REACHED | ( | ) | sparta::SpartaTester::getInstance()->reachedMethod(__FUNCTION__) |
Add this method to be checked against whether or not it was called at least once. This macro can be placed anywhere inside the function expected to be called.
Definition at line 420 of file SpartaTester.hpp.
#define EXPECT_THROW | ( | x | ) |
Determine if the block x correctly throws an exception.
Example usage:
Definition at line 561 of file SpartaTester.hpp.
#define EXPECT_THROW_MSG_CONTAINS | ( | x, | |
expected_msg | |||
) |
Definition at line 639 of file SpartaTester.hpp.
#define EXPECT_THROW_MSG_LONG | ( | x, | |
expected_msg | |||
) |
Determine if the block x correctly throws an exception with the given message on the file and line number.
Example usage:
Definition at line 623 of file SpartaTester.hpp.
#define EXPECT_THROW_MSG_SHORT | ( | x, | |
expected_msg | |||
) |
Determine if the block x correctly throws an exception with the given message (no line number/file)
Example usage:
Definition at line 589 of file SpartaTester.hpp.
#define EXPECT_TRUE | ( | x | ) | sparta::SpartaTester::getInstance()->expect((x), #x, __LINE__, __FILE__) |
Determine if the block x evaluates to true.
Example usage:
Definition at line 446 of file SpartaTester.hpp.
#define EXPECT_WITHIN_EPSILON | ( | x, | |
y | |||
) |
Determine if the block x is equal (using operator= on x) to y within 2x the machine epsilon, as determined by std::numeric_limits<T>::epsilon()
If x and y differ by strictly more than (>) the specified tolerance, the x and y values and the tolerance value will be printed in an error message.
Example usage:
Definition at line 532 of file SpartaTester.hpp.
#define EXPECT_WITHIN_TOLERANCE | ( | x, | |
y, | |||
tol | |||
) |
Determine if the block x is equal (using operator= on x) to y within a specified tolerance.
If x and y differ by more than (>) the specified tolerance, the x and y values and the tolerance value will be printed in an error message.
Example usage:
Definition at line 508 of file SpartaTester.hpp.
#define REPORT_ERROR |
Prints the error code with a nice pretty message.
Example:
Definition at line 737 of file SpartaTester.hpp.
#define TEST_INIT |
Initialized the test. Should be placed OUTSIDE of a code block SOMEWHERE in the test source.
Definition at line 412 of file SpartaTester.hpp.