nlib
NTest.h File Reference

Defines the macro for a basic, simple test. More...

#include <string.h>
#include <new>
#include "nn/nlib/Config.h"
#include "nn/nlib/testing/Printer.h"
#include "nn/nlib/SimpleSingleton.h"
#include "nn/nlib/Nflags.h"

Go to the source code of this file.

Classes

class  nn::nlib::testing::Environment
 Defines the SetUp and TearDown functions that inherit this class and are run globally. More...
 

Namespaces

 nn::nlib
 Implements stream-related classes usually commonly used, various containers, and other gadget classes. nlib_ns is an alias.
 
 nn::nlib::testing
 Framework to test C++ code. View the description of List of testing Library Features.
 

Macros

#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...
 
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...
 
Start Tests
#define RUN_ALL_TESTS()   ::nlib_ns::testing::TestInfo::Run()
 Starts the testing. More...
 
Unconditional Success and Failure
#define FAIL()
 Fails unconditionally and leaves the currently running function.
 
#define SUCCEED()
 Does nothing.
 
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_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_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_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_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_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_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_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_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_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_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.
 

Functions

void nn::nlib::testing::InitNintendoTest (int *argc, char **argv)
 Processes command-line options for the test program.
 
void nn::nlib::testing::InitNintendoTest (int *argc, wchar_t **argv)
 Processes command-line options for the test program.
 
Environment * nn::nlib::testing::AddGlobalTestEnvironment (Environment *env)
 Passes the pointer to Environment and registers the code to run before and after all tests.
 
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...
 

Detailed Description

Defines the macro for a basic, simple test.

Definition in file NTest.h.