VirtualBox

Changeset 21723 in vbox


Ignore:
Timestamp:
Jul 20, 2009 12:39:00 PM (16 years ago)
Author:
vboxsync
Message:

tstUtf8: Test RTStrUtf8ToCurrentCP and RTUtf16ToLatin1 for VERR_NO_TRANSLATION behavior.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/testcase/tstUtf8.cpp

    r21714 r21723  
    823823        }
    824824        uint64_t u64Elapsed = RTTimeNanoTS() - u64Start;
    825         RTTestPrintf(hTest, RTTESTLVL_ALWAYS, "%d in %RI64ns\n", i, u64Elapsed);
     825        RTTestPrintf(hTest, RTTESTLVL_ALWAYS, "%d in %'RI64 ns\n", i, u64Elapsed);
    826826    }
    827827
     
    843843        }
    844844        uint64_t u64Elapsed = RTTimeNanoTS() - u64Start;
    845         RTTestPrintf(hTest, RTTESTLVL_ALWAYS, "%d in %RI64ns\n", i, u64Elapsed);
     845        RTTestPrintf(hTest, RTTESTLVL_ALWAYS, "%d in %'RI64 ns\n", i, u64Elapsed);
    846846    }
    847847
     
    10091009}
    10101010
     1011
    10111012void testLatin1(RTTEST hTest)
    10121013{
    10131014    RTTestSub(hTest, "Latin1 conversion functions");
    1014    
     1015
    10151016    /* Test Utf16 -> Latin1 */
    10161017    size_t cch_szAll = 0;
     
    11621163}
    11631164
     1165
     1166static void testNoTransation(RTTEST hTest)
     1167{
     1168
     1169    /*
     1170     * Try trigger a VERR_NO_TRANSLATION error in convert to
     1171     * current CP to latin-1.
     1172     */
     1173    const RTUTF16 s_swzTest1[] = { 0x2358, 0x2242, 0x2357, 0x2359,  0x22f9, 0x2c4e, 0x0030, 0x0060,
     1174                                   0x0092, 0x00c1, 0x00f2, 0x1f80,  0x0088, 0x2c38, 0x2c30, 0x0000 };
     1175    char *pszTest1;
     1176    int rc = RTUtf16ToUtf8(s_swzTest1, &pszTest1);
     1177    RTTESTI_CHECK_RC_RETV(rc, VINF_SUCCESS);
     1178
     1179    RTTestSub(hTest, "VERR_NO_TRANSLATION/RTStrUtf8ToCurrentCP");
     1180    char *pszOut;
     1181    rc = RTStrUtf8ToCurrentCP(&pszOut, pszTest1);
     1182    if (RT_SUCCESS(rc))
     1183    {
     1184        RTTESTI_CHECK(!strcmp(pszOut, pszTest1));
     1185        RTTestIPrintf(RTTESTLVL_ALWAYS, "CurrentCP is UTF-8 or similar\n");
     1186        RTStrFree(pszOut);
     1187    }
     1188    else
     1189        RTTESTI_CHECK_RC(rc, VERR_NO_TRANSLATION);
     1190
     1191    RTTestSub(hTest, "VERR_NO_TRANSLATION/RTUtf16ToLatin1");
     1192    rc = RTUtf16ToLatin1(s_swzTest1, &pszOut);
     1193    RTTESTI_CHECK_RC(rc, VERR_NO_TRANSLATION);
     1194    if (RT_SUCCESS(rc))
     1195        RTStrFree(pszOut);
     1196
     1197    RTStrFree(pszTest1);
     1198    RTTestSubDone(hTest);
     1199}
     1200
     1201
    11641202int main()
    11651203{
     
    11871225    testLatin1(hTest);
    11881226
     1227    testNoTransation(hTest);
     1228
    11891229    Benchmarks(hTest);
    11901230
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette