- Timestamp:
- Jun 8, 2010 1:15:44 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/tstRTStrFormat.cpp
r29783 r30088 106 106 uint64_t u64 = 0x100; 107 107 #define BUF_SIZE 120 108 char *pszBuf = (char *)RTTestGuardedAllocHead(hTest, BUF_SIZE); 108 char *pszBuf = (char *)RTTestGuardedAllocHead(hTest, BUF_SIZE); 109 char *pszBuf2 = (char *)RTTestGuardedAllocHead(hTest, BUF_SIZE); 109 110 110 111 RTTestSub(hTest, "Basics"); … … 547 548 548 549 /* 550 * Hex formatting. 551 */ 552 RTTestSub(hTest, "Hex dump formatting (%Rhx*)"); 553 static uint8_t const s_abHex1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; 554 cch = RTStrPrintf(pszBuf, BUF_SIZE, "%.1Rhxs", s_abHex1); 555 CHECKSTR("00"); 556 cch = RTStrPrintf(pszBuf, BUF_SIZE, "%.2Rhxs", s_abHex1); 557 CHECKSTR("00 01"); 558 cch = RTStrPrintf(pszBuf, BUF_SIZE, "%Rhxs", s_abHex1); 559 CHECKSTR("00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f"); 560 cch = RTStrPrintf(pszBuf, BUF_SIZE, "%.*Rhxs", sizeof(s_abHex1), s_abHex1); 561 CHECKSTR("00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14"); 562 cch = RTStrPrintf(pszBuf, BUF_SIZE, "%4.*Rhxs", sizeof(s_abHex1), s_abHex1); 563 CHECKSTR("00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14"); 564 cch = RTStrPrintf(pszBuf, BUF_SIZE, "%1.*Rhxs", sizeof(s_abHex1), s_abHex1); 565 CHECKSTR("00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14"); 566 cch = RTStrPrintf(pszBuf, BUF_SIZE, "%256.*Rhxs", sizeof(s_abHex1), s_abHex1); 567 CHECKSTR("00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14"); 568 569 cch = RTStrPrintf(pszBuf, BUF_SIZE, "%4.8Rhxd", s_abHex1); 570 RTStrPrintf(pszBuf2, BUF_SIZE, 571 "%p 0000: 00 01 02 03 ....\n" 572 "%p 0004: 04 05 06 07 ....", 573 &s_abHex1[0], &s_abHex1[4]); 574 CHECKSTR(pszBuf2); 575 576 cch = RTStrPrintf(pszBuf, BUF_SIZE, "%4.6Rhxd", s_abHex1); 577 RTStrPrintf(pszBuf2, BUF_SIZE, 578 "%p 0000: 00 01 02 03 ....\n" 579 "%p 0004: 04 05 ..", 580 &s_abHex1[0], &s_abHex1[4]); 581 CHECKSTR(pszBuf2); 582 583 cch = RTStrPrintf(pszBuf, BUF_SIZE, "%.*Rhxd", sizeof(s_abHex1), s_abHex1); 584 RTStrPrintf(pszBuf2, BUF_SIZE, 585 "%p 0000: 00 01 02 03 04 05 06 07-08 09 0a 0b 0c 0d 0e 0f ................\n" 586 "%p 0010: 10 11 12 13 14 ....." 587 , 588 &s_abHex1[0], &s_abHex1[0x10]); 589 CHECKSTR(pszBuf2); 590 591 /* 549 592 * Custom types. 550 593 */
Note:
See TracChangeset
for help on using the changeset viewer.