Changeset 637 in vbox
- Timestamp:
- Feb 5, 2007 1:31:16 PM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 18266
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/tstStrFormat.cpp
r1 r637 27 27 #include <iprt/uuid.h> 28 28 #include <iprt/string.h> 29 30 #include <stdio.h> 31 32 #ifdef _MSC_VER 33 #define U64C(c) c 34 #else 35 #define U64C(c) c##ULL 36 #endif 29 #include <iprt/stream.h> 37 30 38 31 int main() … … 49 42 if (strcmp(szStr, "u32=16 u64=256 u64=0x100")) 50 43 { 51 printf("error: '%s'\n"44 RTPrintf("error: '%s'\n" 52 45 "wanted 'u32=16 u64=256 u64=0x100'\n", szStr); 53 46 cErrors++; … … 55 48 56 49 /* just big. */ 57 u64 = U 64C(0x7070605040302010);50 u64 = UINT64_C(0x7070605040302010); 58 51 cch = RTStrPrintf(szStr, sizeof(szStr), "u64=%#llx 42=%d u64=%lld 42=%d", u64, 42, u64, 42); 59 52 if (strcmp(szStr, "u64=0x7070605040302010 42=42 u64=8102081627430068240 42=42")) 60 53 { 61 printf("error: '%s'\n"62 "wanted 'u64=0x8070605040302010 42=42 u64=8102081627430068240 42=42'\n", szStr);63 printf("%d\n", (int)(u64 % 10));54 RTPrintf("error: '%s'\n" 55 "wanted 'u64=0x8070605040302010 42=42 u64=8102081627430068240 42=42'\n", szStr); 56 RTPrintf("%d\n", (int)(u64 % 10)); 64 57 cErrors++; 65 58 } 66 59 67 60 /* huge and negative. */ 68 u64 = U 64C(0x8070605040302010);61 u64 = UINT64_C(0x8070605040302010); 69 62 cch = RTStrPrintf(szStr, sizeof(szStr), "u64=%#llx 42=%d u64=%llu 42=%d u64=%lld 42=%d", u64, 42, u64, 42, u64, 42); 70 63 /* Not sure if this is the correct decimal representation... But both */ 71 64 if (strcmp(szStr, "u64=0x8070605040302010 42=42 u64=9255003132036915216 42=42 u64=-9191740941672636400 42=42")) 72 65 { 73 printf("error: '%s'\n"74 "wanted 'u64=0x8070605040302010 42=42 u64=9255003132036915216 42=42 u64=-9191740941672636400 42=42'\n", szStr);75 printf("%d\n", (int)(u64 % 10));66 RTPrintf("error: '%s'\n" 67 "wanted 'u64=0x8070605040302010 42=42 u64=9255003132036915216 42=42 u64=-9191740941672636400 42=42'\n", szStr); 68 RTPrintf("%d\n", (int)(u64 % 10)); 76 69 cErrors++; 77 70 } … … 82 75 if (strcmp(szStr, "u64=0xa0000000 42=42 u64=2684354560 42=42")) 83 76 { 84 printf("error: '%s'\n"85 "wanted 'u64=0xa0000000 42=42 u64=2684354560 42=42'\n", szStr);77 RTPrintf("error: '%s'\n" 78 "wanted 'u64=0xa0000000 42=42 u64=2684354560 42=42'\n", szStr); 86 79 cErrors++; 87 80 } … … 95 88 if (strcmp(szStr, szCorrect)) 96 89 { 97 printf("error: '%s'\n"98 "expected: '%s'\n",99 szStr, szCorrect);90 RTPrintf("error: '%s'\n" 91 "expected: '%s'\n", 92 szStr, szCorrect); 100 93 cErrors++; 101 94 } … … 106 99 if (cch2 < 0) 107 100 { 108 printf("error: RTStrAPrintf failed, cch2=%d\n", cch2);101 RTPrintf("error: RTStrAPrintf failed, cch2=%d\n", cch2); 109 102 cErrors++; 110 103 } 111 104 else if (strcmp(psz, "Hey there! This is a test!")) 112 105 { 113 printf("error: RTStrAPrintf failed\n"114 "got : '%s'\n"115 "wanted: 'Hey there! This is a test!'\n",106 RTPrintf("error: RTStrAPrintf failed\n" 107 "got : '%s'\n" 108 "wanted: 'Hey there! This is a test!'\n", 116 109 psz); 117 110 cErrors++; … … 119 112 else if ((int)strlen(psz) != cch2) 120 113 { 121 printf("error: RTStrAPrintf failed, cch2 == %d expected %u\n", cch2, strlen(psz));114 RTPrintf("error: RTStrAPrintf failed, cch2 == %d expected %u\n", cch2, strlen(psz)); 122 115 cErrors++; 123 116 } … … 129 122 if (strcmp(szStr, out " 42=42 " out " 42=42")) \ 130 123 { \ 131 printf("error(%d): format '%s'\n" \132 " output: '%s'\n" \133 " wanted: '%s'\n", \134 __LINE__, fmt, szStr, out " 42=42 " out " 42=42"); \124 RTPrintf("error(%d): format '%s'\n" \ 125 " output: '%s'\n" \ 126 " wanted: '%s'\n", \ 127 __LINE__, fmt, szStr, out " 42=42 " out " 42=42"); \ 135 128 cErrors++; \ 136 129 } \ 137 130 else if (cch != sizeof(out " 42=42 " out " 42=42") - 1) \ 138 131 { \ 139 printf("error(%d): Invalid length %d returned, expected %u!\n", \140 __LINE__, cch, sizeof(out " 42=42 " out " 42=42") - 1); \132 RTPrintf("error(%d): Invalid length %d returned, expected %u!\n", \ 133 __LINE__, cch, sizeof(out " 42=42 " out " 42=42") - 1); \ 141 134 cErrors++; \ 142 135 } \ … … 313 306 if (strcmp(szStr, szCorrect)) 314 307 { 315 printf("error: '%s'\n"316 "expected: '%s'\n",317 szStr, szCorrect);308 RTPrintf("error: '%s'\n" 309 "expected: '%s'\n", 310 szStr, szCorrect); 318 311 cErrors++; 319 312 } … … 351 344 if (strcmp(szStr, Correct)) \ 352 345 { \ 353 printf("error: '%s'\n" \354 "expected: '%s'\n", szStr, Correct); \346 RTPrintf("error: '%s'\n" \ 347 "expected: '%s'\n", szStr, Correct); \ 355 348 cErrors++; \ 356 349 } … … 401 394 */ 402 395 if (!cErrors) 403 printf("tstStrFormat: SUCCESS\n");404 else 405 printf("tstStrFormat: FAILED - %d errors\n", cErrors);396 RTPrintf("tstStrFormat: SUCCESS\n"); 397 else 398 RTPrintf("tstStrFormat: FAILED - %d errors\n", cErrors); 406 399 return !!cErrors; 407 400 }
Note:
See TracChangeset
for help on using the changeset viewer.