VirtualBox

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


Ignore:
Timestamp:
Sep 3, 2019 12:51:00 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
133080
Message:

IPRT/string.h: Added hexformatting variants that takes an additional 64-bit offset/address argument to be used instead of the memory pointer: %RhXd, %RhXD, %RhXs Also changed space between the pointer and offset to a slash.

File:
1 edited

Legend:

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

    r80496 r80565  
    732732    cch = RTStrPrintf(pszBuf, BUF_SIZE, "%256.*Rhxs", sizeof(s_abHex1), s_abHex1);
    733733    CHECKSTR("00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14");
     734    cch = RTStrPrintf(pszBuf, BUF_SIZE, "%256.*RhXs", sizeof(s_abHex1), s_abHex1, (uint64_t)0x1234);
     735    CHECKSTR("00001234: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14");
     736    cch = RTStrPrintf(pszBuf, BUF_SIZE, "%256.*RhXs", sizeof(s_abHex1), s_abHex1, (uint64_t)0x987654321abcdef);
     737    CHECKSTR("0987654321abcdef: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14");
    734738
    735739    cch = RTStrPrintf(pszBuf, BUF_SIZE, "%4.8Rhxd", s_abHex1);
    736740    RTStrPrintf(pszBuf2, BUF_SIZE,
    737                 "%p 0000: 00 01 02 03 ....\n"
    738                 "%p 0004: 04 05 06 07 ....",
     741                "%p/0000: 00 01 02 03 ....\n"
     742                "%p/0004: 04 05 06 07 ....",
    739743                &s_abHex1[0], &s_abHex1[4]);
    740744    CHECKSTR(pszBuf2);
     
    742746    cch = RTStrPrintf(pszBuf, BUF_SIZE, "%4.6Rhxd", s_abHex1);
    743747    RTStrPrintf(pszBuf2, BUF_SIZE,
    744                 "%p 0000: 00 01 02 03 ....\n"
    745                 "%p 0004: 04 05       ..",
     748                "%p/0000: 00 01 02 03 ....\n"
     749                "%p/0004: 04 05       ..",
    746750                &s_abHex1[0], &s_abHex1[4]);
    747751    CHECKSTR(pszBuf2);
     
    749753    cch = RTStrPrintf(pszBuf, BUF_SIZE, "%.*Rhxd", sizeof(s_abHex1), s_abHex1);
    750754    RTStrPrintf(pszBuf2, BUF_SIZE,
    751                 "%p 0000: 00 01 02 03 04 05 06 07-08 09 0a 0b 0c 0d 0e 0f ................\n"
    752                 "%p 0010: 10 11 12 13 14                                  ....."
     755                "%p/0000: 00 01 02 03 04 05 06 07-08 09 0a 0b 0c 0d 0e 0f ................\n"
     756                "%p/0010: 10 11 12 13 14                                  ....."
    753757                ,
    754758                &s_abHex1[0], &s_abHex1[0x10]);
     759    CHECKSTR(pszBuf2);
     760
     761    cch = RTStrPrintf(pszBuf, BUF_SIZE, "%.*RhXd", sizeof(s_abHex1), s_abHex1, (uint64_t)0xf304);
     762    RTStrPrintf(pszBuf2, BUF_SIZE,
     763                "0000f304/0000: 00 01 02 03 04 05 06 07-08 09 0a 0b 0c 0d 0e 0f ................\n"
     764                "0000f314/0010: 10 11 12 13 14                                  .....");
     765    CHECKSTR(pszBuf2);
     766
     767    cch = RTStrPrintf(pszBuf, BUF_SIZE, "%.*RhXd", sizeof(s_abHex1), s_abHex1, (uint64_t)0x123456789abcdef);
     768    RTStrPrintf(pszBuf2, BUF_SIZE,
     769                "0123456789abcdef/0000: 00 01 02 03 04 05 06 07-08 09 0a 0b 0c 0d 0e 0f ................\n"
     770                "0123456789abcdff/0010: 10 11 12 13 14                                  .....");
    755771    CHECKSTR(pszBuf2);
    756772
Note: See TracChangeset for help on using the changeset viewer.

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