VirtualBox

Changeset 86357 in vbox for trunk


Ignore:
Timestamp:
Sep 30, 2020 6:07:34 PM (4 years ago)
Author:
vboxsync
Message:

tstRTStrFormat: More cleanup.

File:
1 edited

Legend:

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

    r86352 r86357  
    146146
    147147
     148
     149static void testAllocPrintf(RTTEST hTest)
     150{
     151    RTTestSub(hTest, "RTStrAPrintf");
     152    char *psz = (char *)~0;
     153    int cch3 = RTStrAPrintf(&psz, "Hey there! %s%s", "This is a test", "!");
     154    if (cch3 < 0)
     155        RTTestIFailed("RTStrAPrintf failed, cch3=%d\n", cch3);
     156    else if (strcmp(psz, "Hey there! This is a test!"))
     157        RTTestIFailed("RTStrAPrintf failed\n"
     158                      "got   : '%s'\n"
     159                      "wanted: 'Hey there! This is a test!'\n",
     160                      psz);
     161    else if ((int)strlen(psz) != cch3)
     162        RTTestIFailed("RTStrAPrintf failed, cch3 == %d expected %u\n", cch3, strlen(psz));
     163    RTStrFree(psz);
     164}
    148165
    149166
     
    834851}
    835852
     853static void testX86RegisterFormatter(RTTEST hTest, char *pszBuf)
     854{
     855
     856    RTTestSub(hTest, "x86 register format types (%RAx86[*])");
     857    CHECK42("%RAx86[cr0]",  UINT64_C(0x80000011), "80000011{PE,ET,PG}");
     858    CHECK42("%RAx86[cr0]",  UINT64_C(0x80000001), "80000001{PE,PG}");
     859    CHECK42("%RAx86[cr0]",  UINT64_C(0x00000001), "00000001{PE}");
     860    CHECK42("%RAx86[cr0]",  UINT64_C(0x80000000), "80000000{PG}");
     861    CHECK42("%RAx86[cr4]",  UINT64_C(0x80000001), "80000001{VME,unkn=80000000}");
     862    CHECK42("%#RAx86[cr4]", UINT64_C(0x80000001), "0x80000001{VME,unkn=0x80000000}");
     863}
     864
    836865static void testCustomTypes(RTTEST hTest, char *pszBuf)
    837866{
     
    917946     * allocation
    918947     */
    919     RTTestSub(hTest, "RTStrAPrintf");
    920     char *psz = (char *)~0;
    921     int cch3 = RTStrAPrintf(&psz, "Hey there! %s%s", "This is a test", "!");
    922     if (cch3 < 0)
    923         RTTestIFailed("RTStrAPrintf failed, cch3=%d\n", cch3);
    924     else if (strcmp(psz, "Hey there! This is a test!"))
    925         RTTestIFailed("RTStrAPrintf failed\n"
    926                       "got   : '%s'\n"
    927                       "wanted: 'Hey there! This is a test!'\n",
    928                       psz);
    929     else if ((int)strlen(psz) != cch3)
    930         RTTestIFailed("RTStrAPrintf failed, cch3 == %d expected %u\n", cch3, strlen(psz));
    931     RTStrFree(psz);
     948    testAllocPrintf(hTest);
    932949
    933950    /*
     
    970987     * x86 register formatting.
    971988     */
    972     RTTestSub(hTest, "x86 register format types (%RAx86[*])");
    973     CHECK42("%RAx86[cr0]", UINT64_C(0x80000011),    "80000011{PE,ET,PG}");
    974     CHECK42("%RAx86[cr0]", UINT64_C(0x80000001),    "80000001{PE,PG}");
    975     CHECK42("%RAx86[cr0]", UINT64_C(0x00000001),    "00000001{PE}");
    976     CHECK42("%RAx86[cr0]", UINT64_C(0x80000000),    "80000000{PG}");
    977     CHECK42("%RAx86[cr4]", UINT64_C(0x80000001),    "80000001{VME,unkn=80000000}");
    978     CHECK42("%#RAx86[cr4]", UINT64_C(0x80000001),    "0x80000001{VME,unkn=0x80000000}");
     989    testX86RegisterFormatter(hTest, pszBuf);
    979990
    980991    /*
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