Changeset 73979 in vbox for trunk/src/VBox/Runtime/testcase
- Timestamp:
- Aug 30, 2018 1:58:20 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 124715
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/tstRTJson.cpp
r69111 r73979 75 75 { "[ 100, 200 ]", VINF_SUCCESS }, 76 76 { "{ \"1\": 1 }", VINF_SUCCESS }, 77 { "{ \"1\": 1, \"2\": 2 }", VINF_SUCCESS } 77 { "{ \"1\": 1, \"2\": 2 }", VINF_SUCCESS }, 78 { "20", VINF_SUCCESS }, 79 { "-20", VINF_SUCCESS }, 80 { "{\"positive\":20}", VINF_SUCCESS }, 81 { "{\"negative\":-20}", VINF_SUCCESS }, 78 82 }; 79 83 for (unsigned iTest = 0; iTest < RT_ELEMENTS(aTests); iTest++) 80 84 { 85 RTERRINFOSTATIC ErrInfo; 81 86 RTJSONVAL hJsonVal = NIL_RTJSONVAL; 82 int rc = RTJsonParseFromString(&hJsonVal, aTests[iTest].pszJson, NULL);87 int rc = RTJsonParseFromString(&hJsonVal, aTests[iTest].pszJson, RTErrInfoInitStatic(&ErrInfo)); 83 88 if (rc != aTests[iTest].iRcResult) 84 RTTestFailed(hTest, "RTJsonParseFromString() for \"%s\" failed, expected %Rrc got %Rrc\n", 85 aTests[iTest].pszJson, aTests[iTest].iRcResult, rc); 89 { 90 if (RTErrInfoIsSet(&ErrInfo.Core)) 91 RTTestFailed(hTest, "RTJsonParseFromString() for \"%s\" failed, expected %Rrc got %Rrc\n%s", 92 aTests[iTest].pszJson, aTests[iTest].iRcResult, rc, ErrInfo.Core.pszMsg); 93 else 94 RTTestFailed(hTest, "RTJsonParseFromString() for \"%s\" failed, expected %Rrc got %Rrc", 95 aTests[iTest].pszJson, aTests[iTest].iRcResult, rc); 96 } 97 else if (rc == VERR_JSON_MALFORMED && !RTErrInfoIsSet(&ErrInfo.Core)) 98 RTTestFailed(hTest, "RTJsonParseFromString() did not return error info for \"%s\" failed", aTests[iTest].pszJson); 86 99 if (RT_SUCCESS(rc)) 87 100 { … … 275 288 } 276 289 277 int main( )290 int main(int argc, char **argv) 278 291 { 279 292 RTTEST hTest; 280 int rc = RTTestInit AndCreate("tstRTJson", &hTest);293 int rc = RTTestInitExAndCreate(argc, &argv, 0, "tstRTJson", &hTest); 281 294 if (rc) 282 295 return rc; … … 285 298 tstBasic(hTest); 286 299 tstCorrectness(hTest); 300 for (int i = 1; i < argc; i++) 301 { 302 RTTestSubF(hTest, "file %Rbn", argv[i]); 303 RTERRINFOSTATIC ErrInfo; 304 RTJSONVAL hFileValue = NIL_RTJSONVAL; 305 rc = RTJsonParseFromFile(&hFileValue, argv[i], RTErrInfoInitStatic(&ErrInfo)); 306 if (RT_SUCCESS(rc)) 307 RTJsonValueRelease(hFileValue); 308 else if (RTErrInfoIsSet(&ErrInfo.Core)) 309 RTTestFailed(hTest, "%Rrc - %s", rc, ErrInfo.Core.pszMsg); 310 else 311 RTTestFailed(hTest, "%Rrc", rc); 312 } 287 313 288 314 /*
Note:
See TracChangeset
for help on using the changeset viewer.