Changeset 62021 in vbox for trunk/src/VBox/Runtime/testcase
- Timestamp:
- Jul 5, 2016 9:34:17 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/tstRTJson.cpp
r61730 r62021 101 101 static void tstCorrectnessRcForInvalidType(RTTEST hTest, RTJSONVAL hJsonVal, RTJSONVALTYPE enmType) 102 102 { 103 #if 0 /* Enable manuallyor it will assert all over the place for debug builds. */103 #ifndef RT_STRICT /* Enable manually if assertions are enabled or it will assert all over the place for debug builds. */ 104 104 if ( enmType != RTJSONVALTYPE_OBJECT 105 105 && enmType != RTJSONVALTYPE_ARRAY) … … 116 116 RTJSONVAL hJsonValItem = NIL_RTJSONVAL; 117 117 RTTEST_CHECK(hTest, RTJsonValueGetArraySize(hJsonVal) == 0); 118 RTTEST_CHECK_RC(hTest, RTJsonValue GetArraySizeEx(hJsonVal, &cItems), VERR_JSON_VALUE_INVALID_TYPE);119 RTTEST_CHECK_RC(hTest, RTJsonValue GetByIndex(hJsonVal, 0, &hJsonValItem), VERR_JSON_VALUE_INVALID_TYPE);118 RTTEST_CHECK_RC(hTest, RTJsonValueQueryArraySize(hJsonVal, &cItems), VERR_JSON_VALUE_INVALID_TYPE); 119 RTTEST_CHECK_RC(hTest, RTJsonValueQueryByIndex(hJsonVal, 0, &hJsonValItem), VERR_JSON_VALUE_INVALID_TYPE); 120 120 } 121 121 … … 124 124 /* The object access methods should return errors. */ 125 125 RTJSONVAL hJsonValMember = NIL_RTJSONVAL; 126 RTTEST_CHECK_RC(hTest, RTJsonValue GetByName(hJsonVal, "test", &hJsonValMember), VERR_JSON_VALUE_INVALID_TYPE);126 RTTEST_CHECK_RC(hTest, RTJsonValueQueryByName(hJsonVal, "test", &hJsonValMember), VERR_JSON_VALUE_INVALID_TYPE); 127 127 } 128 128 … … 130 130 { 131 131 int64_t i64Num = 0; 132 RTTEST_CHECK_RC(hTest, RTJsonValue GetNumber(hJsonVal, &i64Num), VERR_JSON_VALUE_INVALID_TYPE);132 RTTEST_CHECK_RC(hTest, RTJsonValueQueryInteger(hJsonVal, &i64Num), VERR_JSON_VALUE_INVALID_TYPE); 133 133 } 134 134 … … 137 137 const char *psz = NULL; 138 138 RTTEST_CHECK(hTest, RTJsonValueGetString(hJsonVal) == NULL); 139 RTTEST_CHECK_RC(hTest, RTJsonValue GetStringEx(hJsonVal, &psz), VERR_JSON_VALUE_INVALID_TYPE);139 RTTEST_CHECK_RC(hTest, RTJsonValueQueryString(hJsonVal, &psz), VERR_JSON_VALUE_INVALID_TYPE); 140 140 } 141 141 #endif … … 149 149 uint32_t cItems = 0; 150 150 RTTEST_CHECK(hTest, RTJsonValueGetArraySize(hJsonVal) == 6); 151 RTTEST_CHECK_RC_OK(hTest, RTJsonValueGetArraySizeEx(hJsonVal, &cItems)); 151 RTTEST_CHECK_RC_OK(hTest, RTJsonValueQueryArraySize(hJsonVal, &cItems)); 152 RTTEST_CHECK(hTest, cItems == RTJsonValueGetArraySize(hJsonVal)); 152 153 153 154 for (uint32_t i = 1; i <= 5; i++) … … 155 156 int64_t i64Num = 0; 156 157 RTJSONVAL hJsonValItem = NIL_RTJSONVAL; 157 RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValue GetByIndex(hJsonVal, i - 1, &hJsonValItem));158 RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValueQueryByIndex(hJsonVal, i - 1, &hJsonValItem)); 158 159 RTTEST_CHECK(hTest, RTJsonValueGetType(hJsonValItem) == RTJSONVALTYPE_NUMBER); 159 RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValue GetNumber(hJsonValItem, &i64Num));160 RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValueQueryInteger(hJsonValItem, &i64Num)); 160 161 RTTEST_CHECK(hTest, i64Num == (int64_t)i); 161 162 RTTEST_CHECK(hTest, RTJsonValueRelease(hJsonValItem) == 1); … … 165 166 const char *pszStr = NULL; 166 167 RTJSONVAL hJsonValItem = NIL_RTJSONVAL; 167 RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValue GetByIndex(hJsonVal, 5, &hJsonValItem));168 RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValueQueryByIndex(hJsonVal, 5, &hJsonValItem)); 168 169 RTTEST_CHECK(hTest, RTJsonValueGetType(hJsonValItem) == RTJSONVALTYPE_STRING); 169 RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValue GetStringEx(hJsonValItem, &pszStr));170 RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValueQueryString(hJsonValItem, &pszStr)); 170 171 RTTEST_CHECK(hTest, RTJsonValueGetString(hJsonValItem) == pszStr); 171 172 RTTEST_CHECK(hTest, strcmp(pszStr, "6") == 0); … … 185 186 const char *pszName = NULL; 186 187 RTJSONVAL hJsonValMember = NIL_RTJSONVAL; 187 rc = RTJsonIterator GetValue(hJsonIt, &hJsonValMember, &pszName);188 rc = RTJsonIteratorQueryValue(hJsonIt, &hJsonValMember, &pszName); 188 189 RTTEST_CHECK(hTest, RT_SUCCESS(rc)); 189 190 RTTEST_CHECK(hTest, pszName != NULL); … … 208 209 RTTEST_CHECK(hTest, strcmp(pszName, "string") == 0); 209 210 const char *pszStr = NULL; 210 RTTEST_CHECK_RC_OK(hTest, RTJsonValue GetStringEx(hJsonValMember, &pszStr));211 RTTEST_CHECK_RC_OK(hTest, RTJsonValueQueryString(hJsonValMember, &pszStr)); 211 212 RTTEST_CHECK(hTest, strcmp(pszStr, "test") == 0); 212 213 break; … … 216 217 RTTEST_CHECK(hTest, strcmp(pszName, "number") == 0); 217 218 int64_t i64Num = 0; 218 RTTEST_CHECK_RC_OK(hTest, RTJsonValue GetNumber(hJsonValMember, &i64Num));219 RTTEST_CHECK_RC_OK(hTest, RTJsonValueQueryInteger(hJsonValMember, &i64Num)); 219 220 RTTEST_CHECK(hTest, i64Num == 100); 220 221 break; … … 237 238 RTTEST_CHECK(hTest, rc == VINF_SUCCESS || rc == VERR_JSON_ITERATOR_END); 238 239 if (RT_SUCCESS(rc)) 239 RTTEST_CHECK_RC_OK(hTest, RTJsonIterator GetValue(hJsonIt, &hJsonValMember, &pszName));240 RTTEST_CHECK_RC_OK(hTest, RTJsonIteratorQueryValue(hJsonIt, &hJsonValMember, &pszName)); 240 241 } 241 242 RTJsonIteratorFree(hJsonIt);
Note:
See TracChangeset
for help on using the changeset viewer.