Changeset 108869 in vbox for trunk/src/VBox/Runtime/testcase
- Timestamp:
- Apr 7, 2025 11:36:49 AM (3 weeks ago)
- svn:sync-xref-src-repo-rev:
- 168319
- Location:
- trunk/src/VBox/Runtime/testcase
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/tstRTCRest-1.cpp
r107695 r108869 73 73 { 74 74 RTJSONVAL hValue; 75 RTTESTI_CHECK_RC_OK_RET(RTJsonParseFromString(&hValue, pszJson, pErrInfo ? RTErrInfoInitStatic(pErrInfo) : NULL), rcCheck);75 RTTESTI_CHECK_RC_OK_RET(RTJsonParseFromString(&hValue, 0 /*fFlags*/, pszJson, pErrInfo ? RTErrInfoInitStatic(pErrInfo) : NULL), rcCheck); 76 76 RTCRestJsonPrimaryCursor Cursor(hValue, pszName, pErrInfo ? RTErrInfoInitStatic(pErrInfo) : NULL); 77 77 return pObj->deserializeFromJson(Cursor.m_Cursor); … … 778 778 #if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) 779 779 RTJSONVAL hTmpValue = NIL_RTJSONVAL; 780 int rcTmp = RTJsonParseFromString(&hTmpValue, TST_DBL_MIN_STRING1, NULL);780 int rcTmp = RTJsonParseFromString(&hTmpValue, 0 /*fFlags*/, TST_DBL_MIN_STRING1, NULL); 781 781 RTJsonValueRelease(hTmpValue); 782 782 if (rcTmp == VERR_INVALID_PARAMETER || rcTmp == VERR_OUT_OF_RANGE) -
trunk/src/VBox/Runtime/testcase/tstRTJson.cpp
r106061 r108869 126 126 RTERRINFOSTATIC ErrInfo; 127 127 RTJSONVAL hJsonVal = NIL_RTJSONVAL; 128 int rc = RTJsonParseFromString(&hJsonVal, aTests[iTest].pszJson, RTErrInfoInitStatic(&ErrInfo)); 128 int rc = RTJsonParseFromString(&hJsonVal, 0 /*fFlags*/, aTests[iTest].pszJson, RTErrInfoInitStatic(&ErrInfo)); 129 if (rc != aTests[iTest].iRcResult) 130 { 131 if (RTErrInfoIsSet(&ErrInfo.Core)) 132 RTTestFailed(hTest, "RTJsonParseFromString() for \"%s\" failed, expected %Rrc got %Rrc\n%s", 133 aTests[iTest].pszJson, aTests[iTest].iRcResult, rc, ErrInfo.Core.pszMsg); 134 else 135 RTTestFailed(hTest, "RTJsonParseFromString() for \"%s\" failed, expected %Rrc got %Rrc", 136 aTests[iTest].pszJson, aTests[iTest].iRcResult, rc); 137 } 138 else if (rc == VERR_JSON_MALFORMED && !RTErrInfoIsSet(&ErrInfo.Core)) 139 RTTestFailed(hTest, "RTJsonParseFromString() did not return error info for \"%s\" failed", aTests[iTest].pszJson); 140 if (RT_SUCCESS(rc)) 141 { 142 if (hJsonVal != NIL_RTJSONVAL) 143 RTJsonValueRelease(hJsonVal); 144 else 145 RTTestFailed(hTest, "RTJsonParseFromString() returned success but no value\n"); 146 } 147 else if (hJsonVal != NIL_RTJSONVAL) 148 RTTestFailed(hTest, "RTJsonParseFromString() failed but a JSON value was returned\n"); 149 } 150 } 151 152 /** 153 * Some basic tests to detect malformed JSON5. 154 */ 155 static void tstBasic5(RTTEST hTest) 156 { 157 RTTestSub(hTest, "Basic JSON5 valid/malformed tests"); 158 static struct 159 { 160 const char *pszJson; 161 int iRcResult; 162 } const aTests[] = 163 { 164 { "// This is a single line comment\nnull", VINF_SUCCESS }, 165 { "/* This is a multi line comment\n **/ null", VINF_SUCCESS }, 166 { "\'Single quoted \"string\"\'", VINF_SUCCESS }, 167 { "0xc0dec0ffee", VINF_SUCCESS }, 168 { "-0xffffffffffffffff", VINF_SUCCESS }, 169 { "0xfffffffffffffffff", VERR_JSON_MALFORMED }, 170 { "[0, 1, ]", VINF_SUCCESS }, 171 { "{ \"name\": 1 , }", VINF_SUCCESS }, 172 { "{ name: 1 , }", VINF_SUCCESS }, 173 { "{ _name0: 1 , }", VINF_SUCCESS }, 174 { "{ $name0x: 1 , }", VINF_SUCCESS }, 175 176 }; 177 for (unsigned iTest = 0; iTest < RT_ELEMENTS(aTests); iTest++) 178 { 179 RTERRINFOSTATIC ErrInfo; 180 RTJSONVAL hJsonVal = NIL_RTJSONVAL; 181 int rc = RTJsonParseFromString(&hJsonVal, RTJSON_PARSE_F_JSON5, aTests[iTest].pszJson, RTErrInfoInitStatic(&ErrInfo)); 129 182 if (rc != aTests[iTest].iRcResult) 130 183 { … … 325 378 326 379 RTJSONVAL hJsonVal = NIL_RTJSONVAL; 327 RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonParseFromString(&hJsonVal, g_szJson, NULL));380 RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonParseFromString(&hJsonVal, 0 /*fFlags*/, g_szJson, NULL)); 328 381 329 382 if (hJsonVal != NIL_RTJSONVAL) … … 353 406 354 407 tstBasic(hTest); 408 tstBasic5(hTest); 355 409 tstCorrectness(hTest); 356 410 for (int i = 1; i < argc; i++) … … 359 413 RTERRINFOSTATIC ErrInfo; 360 414 RTJSONVAL hFileValue = NIL_RTJSONVAL; 361 rc = RTJsonParseFromFile(&hFileValue, argv[i], RTErrInfoInitStatic(&ErrInfo));415 rc = RTJsonParseFromFile(&hFileValue, 0 /*fFlags*/, argv[i], RTErrInfoInitStatic(&ErrInfo)); 362 416 if (RT_SUCCESS(rc)) 363 417 RTJsonValueRelease(hFileValue);
Note:
See TracChangeset
for help on using the changeset viewer.