VirtualBox

Changeset 7421 in vbox for trunk/src/VBox/Runtime/testcase


Ignore:
Timestamp:
Mar 10, 2008 4:58:12 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
28856
Message:

Reimplemented RTStrICmp so it's actually UTF-8 and not subject to the current locale.

File:
1 edited

Legend:

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

    r7418 r7421  
    795795
    796796/**
     797 * Test the RTStr*Cmp functions.
     798 */
     799void TstRTStrXCmp(void)
     800{
     801    RTPrintf("tstUtf8: TESTING RTStr*Cmp\n");
     802#define CHECK_DIFF(expr, op) \
     803    do \
     804    { \
     805        int iDiff = expr; \
     806        if (!(iDiff op 0)) \
     807        { \
     808            RTPrintf("tstUtf8(%d): failure - %d " #op " 0: %s\n", __LINE__, iDiff, #expr); \
     809            g_cErrors++; \
     810        } \
     811    } while (0)
     812
     813/** @todo test the non-ascii bits. */
     814
     815    CHECK_DIFF(RTStrCmp(NULL, NULL), == );
     816    CHECK_DIFF(RTStrCmp(NULL, ""), < );
     817    CHECK_DIFF(RTStrCmp("", NULL), > );
     818    CHECK_DIFF(RTStrCmp("", ""), == );
     819    CHECK_DIFF(RTStrCmp("abcdef", "abcdef"), == );
     820    CHECK_DIFF(RTStrCmp("abcdef", "abcde"), > );
     821    CHECK_DIFF(RTStrCmp("abcde", "abcdef"), < );
     822    CHECK_DIFF(RTStrCmp("abcdeg", "abcdef"), > );
     823    CHECK_DIFF(RTStrCmp("abcdef", "abcdeg"), < );
     824    CHECK_DIFF(RTStrCmp("abcdeF", "abcdef"), < );
     825    CHECK_DIFF(RTStrCmp("abcdef", "abcdeF"), > );
     826
     827
     828    CHECK_DIFF(RTStrICmp(NULL, NULL), == );
     829    CHECK_DIFF(RTStrICmp(NULL, ""), < );
     830    CHECK_DIFF(RTStrICmp("", NULL), > );
     831    CHECK_DIFF(RTStrICmp("", ""), == );
     832    CHECK_DIFF(RTStrICmp("abcdef", "abcdef"), == );
     833    CHECK_DIFF(RTStrICmp("abcdef", "abcde"), > );
     834    CHECK_DIFF(RTStrICmp("abcde", "abcdef"), < );
     835    CHECK_DIFF(RTStrICmp("abcdeg", "abcdef"), > );
     836    CHECK_DIFF(RTStrICmp("abcdef", "abcdeg"), < );
     837
     838    CHECK_DIFF(RTStrICmp("abcdeF", "abcdef"), == );
     839    CHECK_DIFF(RTStrICmp("abcdef", "abcdeF"), ==);
     840    CHECK_DIFF(RTStrICmp("ABCDEF", "abcdef"), ==);
     841    CHECK_DIFF(RTStrICmp("abcdef", "ABCDEF"), ==);
     842    CHECK_DIFF(RTStrICmp("AbCdEf", "aBcDeF"), ==);
     843    CHECK_DIFF(RTStrICmp("AbCdEg", "aBcDeF"), > );
     844    CHECK_DIFF(RTStrICmp("AbCdEG", "aBcDef"), > ); /* diff performed on the lower case cp. */
     845}
     846
     847
     848
     849/**
    797850 * Benchmark stuff.
    798851 */
     
    855908    test2();
    856909    test3();
     910    TstRTStrXCmp();
    857911    Benchmarks();
    858912
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