nlib
|
A list of the macros and other features defined in the testing
library. Also see the description of nn::nlib::testing
.
More...
Files | |
file | NTest.h |
Defines the macro for a basic, simple test. | |
file | Pred.h |
Defines a predicate assertion. | |
file | ParamType.h |
Defines a typed test. | |
Macros | |
#define | NLIB_TESTING_OSTREAM ::nlib_ns::testing::detail_func::DummyStream |
Used in place of td::ostream in the testing library. More... | |
#define | FRIEND_TEST(test_case, test_name) friend class NLIB_TESTING_CLASS_NAME_(test_case, test_name) |
The test code is written with the ability to access private members. More... | |
Functions | |
AssertionResult | nn::nlib::testing::FloatLE (const char *expr1, const char *expr2, float val1, float val2) |
Determines if val1 <= val2. [ASSERT|EXPECT] Used by including in PRED_FORMAT2 . More... | |
AssertionResult | nn::nlib::testing::DoubleLE (const char *expr1, const char *expr2, double val1, double val2) |
Determines if val1 <= val2. [ASSERT|EXPECT] Used by including in PRED_FORMAT2 . More... | |
Definition of the Test Function | |
#define | TEST(test_case_name, specific_test_name) NLIB_TEST_(test_case_name, specific_test_name, ::nlib_ns::testing::Test) |
Defines the test variable. More... | |
#define | TEST_F(test_fixture_name, specific_test_name) NLIB_TEST_(test_fixture_name, specific_test_name, test_fixture_name) |
Defines a test function using the test fixture. More... | |
Definition of the Test Function That Parameterizes Values | |
#define | TEST_P(test_case, test_name) |
Defines a test that parameterizes values. More... | |
#define | INSTANTIATE_TEST_CASE_P(prefix, test_case, generator) |
Provides a parameter to test. More... | |
Definition of the Test Function That Parameterizes Types | |
#define | TYPED_TEST_CASE(test_case, types) typedef types::type NLIB_TESTING_TYPELIST(test_case) |
Associates the type list with the test case. More... | |
#define | TYPED_TEST(test_case, test_name) |
Writes a typing test. More... | |
Start Tests | |
#define | RUN_ALL_TESTS() ::nlib_ns::testing::TestInfo::Run() |
Starts the testing. More... | |
Unconditional Success and Failure | |
#define | SUCCEED() |
Does nothing. | |
#define | FAIL() |
Fails unconditionally and leaves the currently running function. | |
Conditional Statement Test (ASSERT_*) | |
#define | ASSERT_TRUE(expr) NLIB_TESTING_BOOLEAN_IMPL_(expr, true, false, NLIB_TESTING_FATAL_) |
Evaluates whether condition is true . If the test fails, control leaves the currently running function. | |
#define | ASSERT_FALSE(expr) NLIB_TESTING_BOOLEAN_IMPL_(!(expr), false, true, NLIB_TESTING_FATAL_) |
Evaluates whether condition is false . If the test fails, control leaves the currently running function. | |
Conditional Statement Test (EXPECT_*) | |
#define | EXPECT_TRUE(expr) NLIB_TESTING_BOOLEAN_IMPL_(expr, true, false, NLIB_TESTING_NONFATAL_) |
If the test fails, control leaves the currently running function, just like ASSERT_TRUE . | |
#define | EXPECT_FALSE(expr) NLIB_TESTING_BOOLEAN_IMPL_(!(expr), false, true, NLIB_TESTING_NONFATAL_) |
If the test fails, control leaves the currently running function, just like ASSERT_FALSE . | |
Value Test (ASSERT_*) | |
#define | ASSERT_EQ(expected, actual) NLIB_TESTING_ASSERT_HELPER_(::nlib_ns::testing::CompEQ, expected, actual) |
Evaluates whether expected == actual. If the test fails, control leaves the currently running function. More... | |
#define | ASSERT_NE(expected, actual) NLIB_TESTING_ASSERT_HELPER_(::nlib_ns::testing::CompNE, expected, actual) |
Evaluates whether val1 != val2. If the test fails, control leaves the currently running function. | |
#define | ASSERT_LT(val1, val2) NLIB_TESTING_ASSERT_HELPER_(::nlib_ns::testing::CompLT, val1, val2) |
Evaluates whether val1 < val2. If the test fails, control leaves the currently running function. | |
#define | ASSERT_LE(val1, val2) NLIB_TESTING_ASSERT_HELPER_(::nlib_ns::testing::CompLE, val1, val2) |
Evaluates whether val1 <= val2. If the test fails, control leaves the currently running function. | |
#define | ASSERT_GT(val1, val2) NLIB_TESTING_ASSERT_HELPER_(::nlib_ns::testing::CompGT, val1, val2) |
Evaluates whether val1 > val2. If the test fails, control leaves the currently running function. | |
#define | ASSERT_GE(val1, val2) NLIB_TESTING_ASSERT_HELPER_(::nlib_ns::testing::CompGE, val1, val2) |
Evaluates whether val1 >= val2. If the test fails, control leaves the currently running function. | |
#define | ASSERT_STREQ(expected, actual) NLIB_TESTING_ASSERT_HELPER_(::nlib_ns::testing::CompStrEq, expected, actual) |
Evaluates whether the two C strings are identical. If the test fails, control leaves the currently running function. | |
#define | ASSERT_STRNE(expected, actual) NLIB_TESTING_ASSERT_HELPER_(::nlib_ns::testing::CompStrNe, expected, actual) |
Evaluates whether the two C strings are not identical. If the test fails, control leaves the currently running function. | |
#define | ASSERT_STRCASEEQ(expected, actual) NLIB_TESTING_ASSERT_HELPER_(::nlib_ns::testing::CompStrCaseEq, expected, actual) |
Tests whether two C strings are the same, ignoring case. If the test fails, control leaves the currently running function. | |
#define | ASSERT_STRCASENE(expected, actual) NLIB_TESTING_ASSERT_HELPER_(::nlib_ns::testing::CompStrCaseNe, expected, actual) |
Tests whether two C strings are not the same, ignoring case. If the test fails, control leaves the currently running function. | |
#define | ASSERT_FLOAT_EQ(expected, actual) NLIB_TESTING_ASSERT_HELPER_(::nlib_ns::testing::CompFloatEq, expected, actual) |
Evaluates whether the two float values are similar. If the test fails, control leaves the currently running function. More... | |
#define | ASSERT_DOUBLE_EQ(expected, actual) NLIB_TESTING_ASSERT_HELPER_(::nlib_ns::testing::CompDoubleEq, expected, actual) |
Evaluates whether the two double values are similar. If the test fails, control leaves the currently running function. More... | |
#define | ASSERT_NEAR(val1, val2, abs_error) |
Evaluates whether the difference between val1 and val2 is within abs_error. If the test fails, control leaves the currently running function. | |
Value Test (EXPECT_*) | |
#define | EXPECT_EQ(expected, actual) NLIB_TESTING_EXPECT_HELPER_(::nlib_ns::testing::CompEQ, expected, actual) |
If the test failed, control leaves the currently running function, just like ASSERT_EQ . | |
#define | EXPECT_NE(expected, actual) NLIB_TESTING_EXPECT_HELPER_(::nlib_ns::testing::CompNE, expected, actual) |
If the test failed, control leaves the currently running function, just like ASSERT_NE . | |
#define | EXPECT_LT(val1, val2) NLIB_TESTING_EXPECT_HELPER_(::nlib_ns::testing::CompLT, val1, val2) |
If the test failed, control leaves the currently running function, just like ASSERT_LT . | |
#define | EXPECT_LE(val1, val2) NLIB_TESTING_EXPECT_HELPER_(::nlib_ns::testing::CompLE, val1, val2) |
If the test failed, control leaves the currently running function, just like ASSERT_LT . | |
#define | EXPECT_GT(val1, val2) NLIB_TESTING_EXPECT_HELPER_(::nlib_ns::testing::CompGT, val1, val2) |
If the test failed, control leaves the currently running function, just like ASSERT_GT . | |
#define | EXPECT_GE(val1, val2) NLIB_TESTING_EXPECT_HELPER_(::nlib_ns::testing::CompGE, val1, val2) |
If the test failed, control leaves the currently running function, just like ASSERT_GE . | |
#define | EXPECT_STREQ(expected, actual) NLIB_TESTING_EXPECT_HELPER_(::nlib_ns::testing::CompStrEq, expected, actual) |
If the test failed, control leaves the currently running function, just like ASSERT_STREQ . | |
#define | EXPECT_STRNE(expected, actual) NLIB_TESTING_EXPECT_HELPER_(::nlib_ns::testing::CompStrNe, expected, actual) |
If the test failed, control leaves the currently running function, just like ASSERT_STRNE . | |
#define | EXPECT_STRCASEEQ(expected, actual) NLIB_TESTING_EXPECT_HELPER_(::nlib_ns::testing::CompStrCaseEq, expected, actual) |
If the test fails, control leaves the currently running function, as in ASSERT_STRCASEEQ . | |
#define | EXPECT_STRCASENE(expected, actual) NLIB_TESTING_EXPECT_HELPER_(::nlib_ns::testing::CompStrCaseNe, expected, actual) |
If the test fails, control leaves the currently running function, as in ASSERT_STRCASENE . | |
#define | EXPECT_FLOAT_EQ(expected, actual) NLIB_TESTING_EXPECT_HELPER_(::nlib_ns::testing::CompFloatEq, expected, actual) |
If the test failed, control leaves the currently running function, just like ASSERT_FLOAT_EQ . | |
#define | EXPECT_DOUBLE_EQ(expected, actual) NLIB_TESTING_EXPECT_HELPER_(::nlib_ns::testing::CompDoubleEq, expected, actual) |
If the test failed, control leaves the currently running function, just like ASSERT_DOUBLE_EQ . | |
#define | EXPECT_NEAR(val1, val2, abs_error) |
If the test failed, control leaves the currently running function, just like ASSERT_NEAR . | |
Used in cases where assertions are used in subroutines | |
#define | SCOPED_TRACE(msg) |
Adds a message that provides information about the location of the scope when displaying a failure message. More... | |
#define | ASSERT_NO_FATAL_FAILURE(statement) |
Evaluates whether ASSERT_* has failed within the subroutine (statement). If the test fails, control leaves the currently running function. More... | |
#define | EXPECT_NO_FATAL_FAILURE(statement) |
The same as EXPECT_NO_FATAL_FAILURE , except control does not leave the currently running function even if it fails. | |
Test of Existing Boolean Functions (ASSERT_PREDn) | |
For functions that return a | |
#define | ASSERT_PRED1(pred, v1) NLIB_TESTING_PRED1_(pred, v1, NLIB_TESTING_FATAL_) |
Evaluates whether pred(v1) is true . If the test fails, control leaves the currently running function. | |
#define | ASSERT_PRED2(pred, v1, v2) NLIB_TESTING_PRED2_(pred, v1, v2, NLIB_TESTING_FATAL_) |
Evaluates whether pred(v1, v2) is true . If the test fails, control leaves the currently running function. | |
#define | ASSERT_PRED3(pred, v1, v2, v3) NLIB_TESTING_PRED3_(pred, v1, v2, v3, NLIB_TESTING_FATAL_) |
Evaluates whether pred(v1, v2, v3) is true . If the test fails, control leaves the currently running function. | |
#define | ASSERT_PRED4(pred, v1, v2, v3, v4) NLIB_TESTING_PRED4_(pred, v1, v2, v3, v4, NLIB_TESTING_FATAL_) |
Evaluates whether pred(v1, v2, v3, v4) is true . If the test fails, control leaves the currently running function. | |
#define | ASSERT_PRED5(pred, v1, v2, v3, v4, v5) NLIB_TESTING_PRED5_(pred, v1, v2, v3, v4, v5, NLIB_TESTING_FATAL_) |
Evaluates whether pred(v1, v2, v3, v4, v5) is true . If the test fails, control leaves the currently running function. | |
Test of Existing Boolean Functions (EXPECT_PREDn) | |
For functions that return a | |
#define | EXPECT_PRED1(pred, v1) NLIB_TESTING_PRED1_(pred, v1, NLIB_TESTING_NONFATAL_) |
Even if the test failed, control does not leave the currently running function, just like ASSERT_PRED1 . | |
#define | EXPECT_PRED2(pred, v1, v2) NLIB_TESTING_PRED2_(pred, v1, v2, NLIB_TESTING_NONFATAL_) |
Even if the test failed, control does not leave the currently running function, just like ASSERT_PRED2 . | |
#define | EXPECT_PRED3(pred, v1, v2, v3) NLIB_TESTING_PRED3_(pred, v1, v2, v3, NLIB_TESTING_NONFATAL_) |
Even if the test failed, control does not leave the currently running function, just like ASSERT_PRED3 . | |
#define | EXPECT_PRED4(pred, v1, v2, v3, v4) NLIB_TESTING_PRED4_(pred, v1, v2, v3, v4, NLIB_TESTING_NONFATAL_) |
Even if the test failed, control does not leave the currently running function, just like ASSERT_PRED4 . | |
#define | EXPECT_PRED5(pred, v1, v2, v3, v4, v5) NLIB_TESTING_PRED5_(pred, v1, v2, v3, v4, v5, NLIB_TESTING_NONFATAL_) |
Even if the test failed, control does not leave the currently running function, just like ASSERT_PRED5 . | |
Customizing the Display by Defining a Test-Only Boolean Function (ASSERT_PRED_FORMATn) | |
Use the following macros to customize the message when | |
#define | ASSERT_PRED_FORMAT1(pred_format, v1) NLIB_TESTING_PRED_FORMAT1_(pred_format, v1, NLIB_TESTING_FATAL_) |
ASSERT_PRED1 may be used by the user to define the display at failure. If the test fails, control leaves the currently running function. More... | |
#define | ASSERT_PRED_FORMAT2(pred_format, v1, v2) NLIB_TESTING_PRED_FORMAT2_(pred_format, v1, v2, NLIB_TESTING_FATAL_) |
ASSERT_PRED2 may be used by the user to define the display at failure. If the test fails, control leaves the currently running function. More... | |
#define | ASSERT_PRED_FORMAT3(pred_format, v1, v2, v3) NLIB_TESTING_PRED_FORMAT3_(pred_format, v1, v2, v3, NLIB_TESTING_FATAL_) |
ASSERT_PRED3 may be used by the user to define the display at failure. If the test fails, control leaves the currently running function. More... | |
#define | ASSERT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) NLIB_TESTING_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, NLIB_TESTING_FATAL_) |
ASSERT_PRED4 may be used by the user to define the display at failure. If the test fails, control leaves the currently running function. More... | |
#define | ASSERT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) NLIB_TESTING_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, NLIB_TESTING_FATAL_) |
ASSERT_PRED5 may be used by the user to define the display at failure. If the test fails, control leaves the currently running function. More... | |
A list of the macros and other features defined in the testing
library. Also see the description of nn::nlib::testing
.
#define ASSERT_DOUBLE_EQ | ( | expected, | |
actual | |||
) | NLIB_TESTING_ASSERT_HELPER_(::nlib_ns::testing::CompDoubleEq, expected, actual) |
Evaluates whether the two double values are similar. If the test fails, control leaves the currently running function.
0
. NaN
values is not considered similar. NaN
significands are all 1
, and exponents are a nonzero value. #define ASSERT_EQ | ( | expected, | |
actual | |||
) | NLIB_TESTING_ASSERT_HELPER_(::nlib_ns::testing::CompEQ, expected, actual) |
Evaluates whether expected == actual. If the test fails, control leaves the currently running function.
NULL
. It must be written as ASSERT_TRUE(NULL == actual)
. #define ASSERT_FLOAT_EQ | ( | expected, | |
actual | |||
) | NLIB_TESTING_ASSERT_HELPER_(::nlib_ns::testing::CompFloatEq, expected, actual) |
Evaluates whether the two float values are similar. If the test fails, control leaves the currently running function.
NaN
values is not considered similar. NaN
significands are all 1
, and exponents are a nonzero value. #define ASSERT_NO_FATAL_FAILURE | ( | statement | ) |
Evaluates whether ASSERT_*
has failed within the subroutine (statement). If the test fails, control leaves the currently running function.
ASSERT_*
fails within a subroutine, the test continues after returning from the subroutine. Use this macro if you do not want to have this behavior. #define ASSERT_PRED_FORMAT1 | ( | pred_format, | |
v1 | |||
) | NLIB_TESTING_PRED_FORMAT1_(pred_format, v1, NLIB_TESTING_FATAL_) |
ASSERT_PRED1
may be used by the user to define the display at failure. If the test fails, control leaves the currently running function.
#define ASSERT_PRED_FORMAT2 | ( | pred_format, | |
v1, | |||
v2 | |||
) | NLIB_TESTING_PRED_FORMAT2_(pred_format, v1, v2, NLIB_TESTING_FATAL_) |
ASSERT_PRED2
may be used by the user to define the display at failure. If the test fails, control leaves the currently running function.
#define ASSERT_PRED_FORMAT3 | ( | pred_format, | |
v1, | |||
v2, | |||
v3 | |||
) | NLIB_TESTING_PRED_FORMAT3_(pred_format, v1, v2, v3, NLIB_TESTING_FATAL_) |
ASSERT_PRED3
may be used by the user to define the display at failure. If the test fails, control leaves the currently running function.
#define ASSERT_PRED_FORMAT4 | ( | pred_format, | |
v1, | |||
v2, | |||
v3, | |||
v4 | |||
) | NLIB_TESTING_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, NLIB_TESTING_FATAL_) |
ASSERT_PRED4
may be used by the user to define the display at failure. If the test fails, control leaves the currently running function.
#define ASSERT_PRED_FORMAT5 | ( | pred_format, | |
v1, | |||
v2, | |||
v3, | |||
v4, | |||
v5 | |||
) | NLIB_TESTING_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, NLIB_TESTING_FATAL_) |
ASSERT_PRED5
may be used by the user to define the display at failure. If the test fails, control leaves the currently running function.
#define FRIEND_TEST | ( | test_case, | |
test_name | |||
) | friend class NLIB_TESTING_CLASS_NAME_(test_case, test_name) |
#define INSTANTIATE_TEST_CASE_P | ( | prefix, | |
test_case, | |||
generator | |||
) |
Provides a parameter to test.
TEST_P
macro. Definition at line 206 of file ParamValue.h.
#define NLIB_TESTING_OSTREAM ::nlib_ns::testing::detail_func::DummyStream |
Used in place of td::ostream
in the testing
library.
testing
library defines its own replacement for std::ostream
. As a result, Google Test compatibility is lost at this point. Using this macro allows the code for operator<<
overload and defining the PrintTo
function to remain the same as with the code for Google Test. NLIB_USE_GTEST
macro is defined when using Google Test, std::ostream
is used. #define RUN_ALL_TESTS | ( | ) | ::nlib_ns::testing::TestInfo::Run() |
Starts the testing.
0
is returned, all tests were successful, and this is used as the return value of the main function of the standard test program. main
function looks something like this. #define SCOPED_TRACE | ( | msg | ) |
Adds a message that provides information about the location of the scope when displaying a failure message.
SCOPED_TRACE
to the code that calls the subroutine adds the filename that SCOPED_TRACE
is called from, the line number, and the message to the error message that is displayed when an error occurs. The effect is removed when the scope of SCOPED_TRACE
is escaped. #define TEST | ( | test_case_name, | |
specific_test_name | |||
) | NLIB_TEST_(test_case_name, specific_test_name, ::nlib_ns::testing::Test) |
Defines the test variable.
#define TEST_F | ( | test_fixture_name, | |
specific_test_name | |||
) | NLIB_TEST_(test_fixture_name, specific_test_name, test_fixture_name) |
Defines a test function using the test fixture.
Test
base class. void SetUpTestCase
and void TearDownTestCase
as static member functions. These functions are each run immediately before and immediately after the overall test case. void SetUp
and void TearDown
member function in protected
. These functions are each run immediately before and immediately after the test. TEST_F
is used in the same method as the TEST
macro, but the group name must be set to the same string as the test fixture class name. #define TEST_P | ( | test_case, | |
test_name | |||
) |
Defines a test that parameterizes values.
TEST_P
macro. nn::nlib::testing::TestWithParam<T>
. T
is the parameter type. TEST_P
macro. The parameter can be found using the GetParam
function. In the case of a critical internal error such as an ASSERT_*
macro failing, any following parameters are not tested. INSTANCE_TEST_CASE_P
macro. The first argument is the identifier of this parameter list. The second argument is the name of the text fixture. The third argument is the parameter generator described below. {begin, begin+step, begin+step+step, ...}
. Does not contain the end parameter. The default value of step is 1
.{v1, v2, ..., vN}
. The current implementation supports values of N up to and including 10
.[begin, end)
.{false, true}
. Definition at line 190 of file ParamValue.h.
#define TYPED_TEST | ( | test_case, | |
test_name | |||
) |
Writes a typing test.
TYPED_TEST_CASE
macro. Definition at line 61 of file ParamType.h.
#define TYPED_TEST_CASE | ( | test_case, | |
types | |||
) | typedef types::type NLIB_TESTING_TYPELIST(test_case) |
Associates the type list with the test case.
TYPED_TEST_CASE
macro. Definition at line 59 of file ParamType.h.
nn::nlib::testing::DoubleLE | ( | const char * | expr1, |
const char * | expr2, | ||
double | val1, | ||
double | val2 | ||
) |
Determines if val1 <= val2. [ASSERT|EXPECT] Used by including in PRED_FORMAT2
.
[in] | expr1 | val1 as a string. |
[in] | expr2 | val2 as a string. |
[in] | val1 | double -type value. |
[in] | val2 | double -type value. |
AssertionResult
type.double
type comparison, this test succeeds if val1 and val2 are similar. The thresholds are the same as for ASSERT_DOUBLE_EQ
. nn::nlib::testing::FloatLE | ( | const char * | expr1, |
const char * | expr2, | ||
float | val1, | ||
float | val2 | ||
) |
Determines if val1 <= val2. [ASSERT|EXPECT] Used by including in PRED_FORMAT2
.
[in] | expr1 | val1 as a string. |
[in] | expr2 | val2 as a string. |
[in] | val1 | float -type value. |
[in] | val2 | float -type value. |
AssertionResult
type.float
type comparison, this test succeeds if val1 and val2 are similar. The thresholds are the same as for ASSERT_FLOAT_EQ
. © 2012-2017 Nintendo Co., Ltd. All rights reserved.