Changeset 86357 in vbox
- Timestamp:
- Sep 30, 2020 6:07:34 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/tstRTStrFormat.cpp
r86352 r86357 146 146 147 147 148 149 static 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 } 148 165 149 166 … … 834 851 } 835 852 853 static 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 836 865 static void testCustomTypes(RTTEST hTest, char *pszBuf) 837 866 { … … 917 946 * allocation 918 947 */ 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); 932 949 933 950 /* … … 970 987 * x86 register formatting. 971 988 */ 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); 979 990 980 991 /*
Note:
See TracChangeset
for help on using the changeset viewer.