VirtualBox

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


Ignore:
Timestamp:
Oct 8, 2010 8:11:27 AM (14 years ago)
Author:
vboxsync
Message:

RTUuidFromUtf16: bug fix + testcase

File:
1 edited

Legend:

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

    r32994 r32995  
    115115    rc = RTUuidToUtf16(&Uuid, wsz, sizeof(wsz)); CHECK_RC();
    116116    RTTEST_CHECK(hTest, RTUtf16Len(wsz) == RTUUID_STR_LENGTH - 1);
     117
     118    RTUTF16 *pwsz;
     119    rc = RTStrToUtf16(sz2, &pwsz);
     120    RTTEST_CHECK(hTest, rc == VINF_SUCCESS);
     121    if (RT_SUCCESS(rc))
     122    {
     123        RTTESTI_CHECK_RC(RTUuidFromUtf16(&Uuid2, pwsz), VINF_SUCCESS);
     124        RTTEST_CHECK(hTest, RTUuidCompare(&Uuid, &Uuid2) == 0);
     125        RTUTF16 *pwsz2 = (RTUTF16*)RTTestGuardedAllocTail(hTest, 2 * (RTUUID_STR_LENGTH + 2));
     126        if (pwsz2)
     127        {
     128            memcpy(pwsz2, pwsz, 2 * (RTUUID_STR_LENGTH + 2));
     129            RTTESTI_CHECK_RC(RTUuidFromUtf16(&Uuid2, pwsz2), VINF_SUCCESS);
     130            RTTEST_CHECK(hTest, RTUuidCompare(&Uuid, &Uuid2) == 0);
     131            for (unsigned off = 1; off < RTUUID_STR_LENGTH + 2; off++)
     132            {
     133                RTUTF16 *pwsz3 = pwsz2 + off;
     134                memcpy(pwsz3, pwsz, 2 * (RTUUID_STR_LENGTH + 1 - off));
     135                pwsz3[RTUUID_STR_LENGTH + 1 - off] = 0;
     136                RTTESTI_CHECK_RC(RTUuidFromUtf16(&Uuid2, pwsz3), VERR_INVALID_UUID_FORMAT);
     137            }
     138            RTTestGuardedFree(hTest, pwsz2);
     139        }
     140        RTUtf16Free(pwsz);
     141    }
    117142
    118143    RTTestSub(hTest, "RTUuidFromUtf16");
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