Changeset 25801 in vbox
- Timestamp:
- Jan 13, 2010 2:08:11 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/tstRTStrFormat.cpp
r25596 r25801 65 65 66 66 67 static void testNested(int iLine, const char *pszExpect, const char *pszFormat, ...) 68 { 69 size_t cchExpect = strlen(pszExpect); 70 char szBuf[512]; 71 72 va_list va; 73 va_start(va, pszFormat); 74 size_t cch = RTStrPrintf(szBuf, sizeof(szBuf), "%N", pszFormat, va); 75 va_end(va); 76 if (strcmp(szBuf, pszExpect)) 77 RTTestIFailed("at line %d: nested format '%s'\n" 78 " output: '%s'\n" 79 " wanted: '%s'\n", 80 iLine, pszFormat, szBuf, pszExpect); 81 else if (cch != cchExpect) 82 RTTestIFailed("at line %d: Invalid length %d returned, expected %u!\n", 83 iLine, cch, cchExpect); 84 85 va_start(va, pszFormat); 86 cch = RTStrPrintf(szBuf, sizeof(szBuf), "%uxxx%Nyyy%u", 43, pszFormat, va, 43); 87 va_end(va); 88 if ( strncmp(szBuf, "43xxx", 5) 89 || strncmp(szBuf + 5, pszExpect, cchExpect) 90 || strcmp( szBuf + 5 + cchExpect, "yyy43") ) 91 RTTestIFailed("at line %d: nested format '%s'\n" 92 " output: '%s'\n" 93 " wanted: '43xxx%syyy43'\n", 94 iLine, pszFormat, szBuf, pszExpect); 95 else if (cch != 5 + cchExpect + 5) 96 RTTestIFailed("at line %d: Invalid length %d returned, expected %u!\n", 97 iLine, cch, 5 + cchExpect + 5); 98 } 99 100 67 101 int main() 68 102 { … … 126 160 "expected: '%s'\n", 127 161 pszBuf, szCorrect); 162 163 /* 164 * Nested 165 */ 166 RTTestSub(hTest, "Nested (%N)"); 167 testNested(__LINE__, "42 2684354560 42 asdf 42", "42 %u 42 %s 42", 2684354560, "asdf"); 168 testNested(__LINE__, "", ""); 128 169 129 170 /*
Note:
See TracChangeset
for help on using the changeset viewer.