int main(int argc, char** argv)
{
    int retCode = EXIT_SUCCESS;
    int verbosity = 2;

    XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity);

    if(XTESTS_START_RUNNER("test.component.core.initialisation_sequence", verbosity))
    {
        if(XTESTS_CASE_BEGIN("Pantheios initialisation sequence", ""))
        {
            int r;

            XTESTS_TEST_INTEGER_EQUAL(0, s_feInitValue);
            XTESTS_TEST_INTEGER_EQUAL(0, s_beInitValue);

            r = pantheios_init();

            if(r < 0)
            {
                XTESTS_FAIL_WITH_QUALIFIER("failed to initialise Pantheios", pantheios_getInitCodeString(r));
            }
            else
            {
                XTESTS_TEST_INTEGER_EQUAL(1, s_feInitValue);
                XTESTS_TEST_INTEGER_EQUAL(1, s_beInitValue);

                pantheios_uninit();

                XTESTS_TEST_INTEGER_EQUAL(2, s_feInitValue);
                XTESTS_TEST_INTEGER_EQUAL(2, s_beInitValue);
            }

            XTESTS_CASE_END("Pantheios initialisation sequence");
        }

        XTESTS_PRINT_RESULTS();

        XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode);
    }

    return retCode;
}
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;
}
static int main_(int argc, char** argv)
{
    int retCode = EXIT_SUCCESS;
    int verbosity = 2;

    static PAN_CHAR_T const* strings[] =
    {
            PANTHEIOS_LITERAL_STRING("abc")
        ,   PANTHEIOS_LITERAL_STRING("ABC")
        ,   PANTHEIOS_LITERAL_STRING("abcdefghijklmnopqrstuvwxyz")
        ,   PANTHEIOS_LITERAL_STRING("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
        ,   PANTHEIOS_LITERAL_STRING("abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
    };
    static int severities[] =
    {
            PANTHEIOS_SEV_DEBUG
        ,   PANTHEIOS_SEV_INFORMATIONAL
        ,   PANTHEIOS_SEV_NOTICE
        ,   PANTHEIOS_SEV_WARNING
        ,   PANTHEIOS_SEV_ERROR
        ,   PANTHEIOS_SEV_CRITICAL
        ,   PANTHEIOS_SEV_ALERT
        ,   PANTHEIOS_SEV_EMERGENCY
    };

    XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity);

    if(XTESTS_START_RUNNER("test.unit.be.COMErrorObject", verbosity))
    {
        /* Case 1 - verifying be.COMErrorObject, with flags 0 */
        if(!XTESTS_CASE_BEGIN("case-1", "verifying be.COMErrorObject, with flags 0"))
        {
            retCode = EXIT_FAILURE;
        }
        else
        {
            pan_be_COMErrorObject_init_t    init;

            init.flags  =   0
//                      |   PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
//                      |   PANTHEIOS_BE_INIT_F_NO_THREAD_ID
                        |   PANTHEIOS_BE_INIT_F_NO_SEVERITY
                        ;

            void*   token;
            int     res = pantheios_be_COMErrorObject_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);

            if(PANTHEIOS_INIT_RC_SUCCESS != res)
            {
                XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.COMErrorObject", pantheios::getInitErrorString(res));
            }
            else
            {
                { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(severities); ++i)
                {
                    { for(size_t j = 0; j != STLSOFT_NUM_ELEMENTS(strings); ++j)
                    {
                        const int severity = severities[i];

                        pantheios_be_COMErrorObject_logEntry(NULL, token, severity, strings[j], stlsoft::c_str_len(strings[j]));

                        if( PANTHEIOS_SEV_DEBUG == severity ||
                            PANTHEIOS_SEV_INFORMATIONAL == severity)
                        {
                            ;   // be.COMErrorObject does not write out debug-level or informational-level messages
                        }
                        else
                        {
                            comstl::errorinfo_desc  ed;

                            XTESTS_TEST_STRING_EQUAL(strings[j], ed);
                        }
                    }}
                }}

                pantheios_be_COMErrorObject_uninit(token);
            }

            XTESTS_CASE_END("");
        }

        /* Case 2 - verifying be.COMErrorObject, with PANTHEIOS_BE_COMERROROBJECT_F_DONT_OVERWRITE_EXISTING flag */
        if(!XTESTS_CASE_BEGIN("case-2", "verifying be.COMErrorObject, with PANTHEIOS_BE_COMERROROBJECT_F_DONT_OVERWRITE_EXISTING flag"))
        {
            retCode = EXIT_FAILURE;
        }
        else
        {
            pan_be_COMErrorObject_init_t    init;

            init.flags  =   0
//                      |   PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
//                      |   PANTHEIOS_BE_INIT_F_NO_THREAD_ID
                        |   PANTHEIOS_BE_INIT_F_NO_SEVERITY
                        |   PANTHEIOS_BE_COMERROROBJECT_F_DONT_OVERWRITE_EXISTING
                        ;

            void*   token;
            int     res = pantheios_be_COMErrorObject_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);

            if(PANTHEIOS_INIT_RC_SUCCESS != res)
            {
                XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.COMErrorObject", pantheios::getInitErrorString(res));
            }
            else
            {
                { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(severities); ++i)
                {
                    { for(size_t j = 0; j != STLSOFT_NUM_ELEMENTS(strings); ++j)
                    {
                        const int severity = severities[i];

                        comstl::set_error_info(L"the first string");

                        pantheios_be_COMErrorObject_logEntry(NULL, token, severity, strings[j], stlsoft::c_str_len(strings[j]));

                        if( PANTHEIOS_SEV_DEBUG == severity ||
                            PANTHEIOS_SEV_INFORMATIONAL == severity)
                        {
                            ;   // be.COMErrorObject does not write out debug-level or informational-level messages
                        }
                        else
                        {
                            comstl::errorinfo_desc  ed;

                            XTESTS_TEST_MULTIBYTE_STRING_EQUAL("the first string", ed);
                        }
                    }}
                }}

                pantheios_be_COMErrorObject_uninit(token);
            }

            XTESTS_CASE_END("");
        }

        XTESTS_PRINT_RESULTS();

        XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode);
    }

    return retCode;
}