static void test_1_01() { { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(s_severities); ++i) { const int severity = s_severities[i]; // 1. Setup pantheios::be::test::reset(); // 2. Create test data pantheios::pantheios_logprintf(severity, PSTR("abc")); // 3. Verification pantheios::be::test::Results results = pantheios::be::test::results(); if(!results.empty()) // Do test here, so will work with any back-end { XTESTS_TEST(1 == results.size()); PANTHEIOS_SEV_LEVELS_EQUAL(severity, results[0].severity); XTESTS_TEST_STRING_EQUAL(PSTR("abc"), results[0].statement); } }} }
static void test_1_04() { { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(s_severities); ++i) { const int severity = s_severities[i]; // 1. Setup pantheios::be::test::reset(); // 2. Create test data pantheios::pantheios_logputs(severity, PSTR("abc")); pantheios::pantheios_logputs(severity, PSTR("def")); pantheios::pantheios_logputs(severity, PSTR("abcdefghijklmnopqrstuvwxyz")); pantheios::pantheios_logputs(severity, PSTR("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")); // 3. Verification pantheios::be::test::Results results = pantheios::be::test::results(); if(!results.empty()) // Do test here, so will work with any back-end { XTESTS_TEST(4 == results.size()); PANTHEIOS_SEV_LEVELS_EQUAL(severity, results[0].severity); XTESTS_TEST_STRING_EQUAL(PSTR("abc"), results[0].statement); PANTHEIOS_SEV_LEVELS_EQUAL(severity, results[1].severity); XTESTS_TEST_STRING_EQUAL(PSTR("def"), results[1].statement); PANTHEIOS_SEV_LEVELS_EQUAL(severity, results[2].severity); XTESTS_TEST_STRING_EQUAL(PSTR("abcdefghijklmnopqrstuvwxyz"), results[2].statement); PANTHEIOS_SEV_LEVELS_EQUAL(severity, results[3].severity); XTESTS_TEST_STRING_EQUAL(PSTR("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"), results[3].statement); } }} }
static void test_1_03() { // 1. Setup pantheios::be::test::reset(); // 2. Create test data pantheios::pantheios_logprintf(pantheios::error(0x01234567), PSTR("abc")); // 3. Verification pantheios::be::test::Results results = pantheios::be::test::results(); XTESTS_TEST(!results.empty()); XTESTS_TEST(1 == results.size()); PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_ERROR | (0x01234567 << 4), results[0].severity); XTESTS_TEST_STRING_EQUAL(PSTR("abc"), results[0].statement); }
static void test_1_02() { // 1. Setup pantheios::be::test::reset(); // 2. Create test data pantheios::log(pantheios::notice(1), PSTR("abc")); // 3. Verification pantheios::be::test::Results results = pantheios::be::test::results(); XTESTS_TEST(!results.empty()); XTESTS_TEST(1 == results.size()); XTESTS_TEST_STRING_EQUAL(PSTR("abc"), results[0].statement); PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_NOTICE | (1 << 4), results[0].severity); }
int main(int argc, char** argv) { int retCode = EXIT_SUCCESS; int verbosity = 2; XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); if(XTESTS_START_RUNNER("test.unit.levels.dynamic_initialisation", verbosity)) { /* Case 1 - verifying Pantheios levels instances */ if(!XTESTS_CASE_BEGIN("case-1", "verifying Pantheios levels instances")) { retCode = EXIT_FAILURE; } else { PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_EMERGENCY, ::pantheios::emergency); PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_ALERT, ::pantheios::alert); PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_CRITICAL, ::pantheios::critical); PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_ERROR, ::pantheios::error); PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_WARNING, ::pantheios::warning); PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_NOTICE, ::pantheios::notice); PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_INFORMATIONAL, ::pantheios::informational); PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_DEBUG, ::pantheios::debug); XTESTS_CASE_END(""); } /* Case 2 - verifying non-local constants */ if(!XTESTS_CASE_BEGIN("case-2", "verifying non-local constants")) { retCode = EXIT_FAILURE; } else { PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_EMERGENCY, ::emergency); PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_ALERT, ::alert); PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_CRITICAL, ::critical); PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_ERROR, ::error); PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_WARNING, ::warning); PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_NOTICE, ::notice); PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_INFORMATIONAL, ::informational); PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_DEBUG, ::debug); XTESTS_CASE_END(""); } /* Case 3 - verifying dynamic initialisation levels instances */ if(!XTESTS_CASE_BEGIN("case-3", "verifying dynamic initialisation levels instances")) { retCode = EXIT_FAILURE; } else { PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_EMERGENCY, levels.emergency); PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_ALERT, levels.alert); PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_CRITICAL, levels.critical); PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_ERROR, levels.error); PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_WARNING, levels.warning); PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_NOTICE, levels.notice); PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_INFORMATIONAL, levels.informational); PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_DEBUG, levels.debug); XTESTS_CASE_END(""); } XTESTS_PRINT_RESULTS(); XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); } return retCode; }