///////////////////////////////////////////////////////////////
//
// SharedUtil_String_Tests
//
// Test behaviour of strings
//
///////////////////////////////////////////////////////////////
void SharedUtil_String_Tests ( void )
{
    // Formatting
    {
        SString strTemp1 ( "name:" PRSinS, "dave" );
        SString strTemp2 ( "name:" PRWinS, L"dave" );
        WString wstrTemp3 ( L"name:" PRSinW, "dave" );
        WString wstrTemp4 ( L"name:" PRWinW, L"dave" );

        assert ( strTemp1 == "name:dave" );
        assert ( strTemp2 == "name:dave" );
        assert ( wstrTemp3 == L"name:dave" );
        assert ( wstrTemp4 == L"name:dave" );
    }

    // To/From Ansi
    {
        SString strTemp1 = "abcABC 123";
        WString wstrTemp2 = "defDEF 456";
        WString wstrTemp3 = L"ghiGHI 789";

        assert ( wstrTemp2 == L"defDEF 456" );

        SString strTemp2 = wstrTemp2.ToAnsi ();
        SString strTemp3 = wstrTemp3.ToAnsi ();

        assert ( strTemp2 == "defDEF 456" );
        assert ( strTemp3 == "ghiGHI 789" );
    }
}
Beispiel #2
0
///////////////////////////////////////////////////////////////
//
// SharedUtil_String_Tests
//
// Test behaviour of strings
//
///////////////////////////////////////////////////////////////
void SharedUtil_String_Tests ( void )
{
    // Formatting
    {
        SString strTemp1 ( "name:" PRSinS, "dave" );
        SString strTemp2 ( "name:" PRWinS, L"dave" );
        WString wstrTemp3 ( L"name:" PRSinW, "dave" );
        WString wstrTemp4 ( L"name:" PRWinW, L"dave" );

        assert ( strTemp1 == "name:dave" );
        assert ( strTemp2 == "name:dave" );
        assert ( wstrTemp3 == L"name:dave" );
        assert ( wstrTemp4 == L"name:dave" );
    }

    // To/From Ansi
    {
        SString strTemp1 = "abcABC 123";
        WString wstrTemp2 = "defDEF 456";
        WString wstrTemp3 = L"ghiGHI 789";

        assert ( wstrTemp2 == L"defDEF 456" );

        SString strTemp2 = wstrTemp2.ToAnsi ();
        SString strTemp3 = wstrTemp3.ToAnsi ();

        assert ( strTemp2 == "defDEF 456" );
        assert ( strTemp3 == "ghiGHI 789" );
    }

    // Escaping URL arguments
    {
        TEST_FUNCTION
            SStringX strInputA( (const char*)a, sizeof( a ) );
            SString strEscaped = EscapeURLArgument( strInputA );
            SString strUnescaped = UnescapeString ( strEscaped, '%' );
            assert ( strEscaped == result );
            assert ( strInputA == strUnescaped );
        TEST_VARS
            const uchar a[5];
            const char* result;
        TEST_DATA
            { {0x00, 0x10, 0x20, 0x21, 0x22},       "%00%10%20%21%22" },
            { {0x7F, 0x80, 0x81, 0xFE, 0xFF},       "%7F%80%81%FE%FF" },