VirtualBox

Changeset 62021 in vbox for trunk/src/VBox/Runtime/testcase


Ignore:
Timestamp:
Jul 5, 2016 9:34:17 AM (8 years ago)
Author:
vboxsync
Message:

Runtime/RTJson: Fix review todos

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/testcase/tstRTJson.cpp

    r61730 r62021  
    101101static void tstCorrectnessRcForInvalidType(RTTEST hTest, RTJSONVAL hJsonVal, RTJSONVALTYPE enmType)
    102102{
    103 #if 0 /* Enable manually or 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. */
    104104    if (   enmType != RTJSONVALTYPE_OBJECT
    105105        && enmType != RTJSONVALTYPE_ARRAY)
     
    116116        RTJSONVAL hJsonValItem = NIL_RTJSONVAL;
    117117        RTTEST_CHECK(hTest, RTJsonValueGetArraySize(hJsonVal) == 0);
    118         RTTEST_CHECK_RC(hTest, RTJsonValueGetArraySizeEx(hJsonVal, &cItems), VERR_JSON_VALUE_INVALID_TYPE);
    119         RTTEST_CHECK_RC(hTest, RTJsonValueGetByIndex(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);
    120120    }
    121121
     
    124124        /* The object access methods should return errors. */
    125125        RTJSONVAL hJsonValMember = NIL_RTJSONVAL;
    126         RTTEST_CHECK_RC(hTest, RTJsonValueGetByName(hJsonVal, "test", &hJsonValMember), VERR_JSON_VALUE_INVALID_TYPE);
     126        RTTEST_CHECK_RC(hTest, RTJsonValueQueryByName(hJsonVal, "test", &hJsonValMember), VERR_JSON_VALUE_INVALID_TYPE);
    127127    }
    128128
     
    130130    {
    131131        int64_t i64Num = 0;
    132         RTTEST_CHECK_RC(hTest, RTJsonValueGetNumber(hJsonVal, &i64Num), VERR_JSON_VALUE_INVALID_TYPE);
     132        RTTEST_CHECK_RC(hTest, RTJsonValueQueryInteger(hJsonVal, &i64Num), VERR_JSON_VALUE_INVALID_TYPE);
    133133    }
    134134
     
    137137        const char *psz = NULL;
    138138        RTTEST_CHECK(hTest, RTJsonValueGetString(hJsonVal) == NULL);
    139         RTTEST_CHECK_RC(hTest, RTJsonValueGetStringEx(hJsonVal, &psz), VERR_JSON_VALUE_INVALID_TYPE);
     139        RTTEST_CHECK_RC(hTest, RTJsonValueQueryString(hJsonVal, &psz), VERR_JSON_VALUE_INVALID_TYPE);
    140140    }
    141141#endif
     
    149149    uint32_t cItems = 0;
    150150    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));
    152153
    153154    for (uint32_t i = 1; i <= 5; i++)
     
    155156        int64_t i64Num = 0;
    156157        RTJSONVAL hJsonValItem = NIL_RTJSONVAL;
    157         RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValueGetByIndex(hJsonVal, i - 1, &hJsonValItem));
     158        RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValueQueryByIndex(hJsonVal, i - 1, &hJsonValItem));
    158159        RTTEST_CHECK(hTest, RTJsonValueGetType(hJsonValItem) == RTJSONVALTYPE_NUMBER);
    159         RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValueGetNumber(hJsonValItem, &i64Num));
     160        RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValueQueryInteger(hJsonValItem, &i64Num));
    160161        RTTEST_CHECK(hTest, i64Num == (int64_t)i);
    161162        RTTEST_CHECK(hTest, RTJsonValueRelease(hJsonValItem) == 1);
     
    165166    const char *pszStr = NULL;
    166167    RTJSONVAL hJsonValItem = NIL_RTJSONVAL;
    167     RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValueGetByIndex(hJsonVal, 5, &hJsonValItem));
     168    RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValueQueryByIndex(hJsonVal, 5, &hJsonValItem));
    168169    RTTEST_CHECK(hTest, RTJsonValueGetType(hJsonValItem) == RTJSONVALTYPE_STRING);
    169     RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValueGetStringEx(hJsonValItem, &pszStr));
     170    RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValueQueryString(hJsonValItem, &pszStr));
    170171    RTTEST_CHECK(hTest, RTJsonValueGetString(hJsonValItem) == pszStr);
    171172    RTTEST_CHECK(hTest, strcmp(pszStr, "6") == 0);
     
    185186        const char *pszName = NULL;
    186187        RTJSONVAL hJsonValMember = NIL_RTJSONVAL;
    187         rc = RTJsonIteratorGetValue(hJsonIt, &hJsonValMember, &pszName);
     188        rc = RTJsonIteratorQueryValue(hJsonIt, &hJsonValMember, &pszName);
    188189        RTTEST_CHECK(hTest, RT_SUCCESS(rc));
    189190        RTTEST_CHECK(hTest, pszName != NULL);
     
    208209                    RTTEST_CHECK(hTest, strcmp(pszName, "string") == 0);
    209210                    const char *pszStr = NULL;
    210                     RTTEST_CHECK_RC_OK(hTest, RTJsonValueGetStringEx(hJsonValMember, &pszStr));
     211                    RTTEST_CHECK_RC_OK(hTest, RTJsonValueQueryString(hJsonValMember, &pszStr));
    211212                    RTTEST_CHECK(hTest, strcmp(pszStr, "test") == 0);
    212213                    break;
     
    216217                    RTTEST_CHECK(hTest, strcmp(pszName, "number") == 0);
    217218                    int64_t i64Num = 0;
    218                     RTTEST_CHECK_RC_OK(hTest, RTJsonValueGetNumber(hJsonValMember, &i64Num));
     219                    RTTEST_CHECK_RC_OK(hTest, RTJsonValueQueryInteger(hJsonValMember, &i64Num));
    219220                    RTTEST_CHECK(hTest, i64Num == 100);
    220221                    break;
     
    237238            RTTEST_CHECK(hTest, rc == VINF_SUCCESS || rc == VERR_JSON_ITERATOR_END);
    238239            if (RT_SUCCESS(rc))
    239                 RTTEST_CHECK_RC_OK(hTest, RTJsonIteratorGetValue(hJsonIt, &hJsonValMember, &pszName));
     240                RTTEST_CHECK_RC_OK(hTest, RTJsonIteratorQueryValue(hJsonIt, &hJsonValMember, &pszName));
    240241        }
    241242        RTJsonIteratorFree(hJsonIt);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette