VirtualBox

vbox的更動 36563 路徑 trunk/src/VBox/Runtime/testcase


忽略:
時間撮記:
2011-4-5 下午03:28:31 (14 年 以前)
作者:
vboxsync
訊息:

iprt-cpp: More RTC*List methods. Added explicit constructors to the specializations.

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Runtime/testcase/tstIprtList.cpp

    r36532 r36563  
    218218
    219219    /*
     220     * Contains
     221     */
     222    L<T1, T2> testList2;
     223
     224    /* Check full list. */
     225    RTTESTI_CHECK( testList.contains(paTestData[0]));
     226    RTTESTI_CHECK( testList.contains(paTestData[cTestItems / 2]));
     227    RTTESTI_CHECK( testList.contains(paTestData[cTestItems - 1]));
     228    RTTESTI_CHECK(!testList.contains(T1()));
     229    /* Check empty list. */
     230    RTTESTI_CHECK(!testList2.contains(paTestData[0]));
     231    RTTESTI_CHECK(!testList2.contains(paTestData[cTestItems / 2]));
     232    RTTESTI_CHECK(!testList2.contains(paTestData[cTestItems - 1]));
     233    RTTESTI_CHECK(!testList2.contains(T1()));
     234
     235    /*
    220236     * Copy operator
    221237     */
    222     L<T1, T2> testList2(testList);
    223 
    224     /* Check that all is correctly appended. */
    225     RTTESTI_CHECK_RETV(testList2.size() == cTestItems);
    226     for (size_t i = 0; i < testList2.size(); ++i)
    227         RTTESTI_CHECK(testList2.at(i) == paTestData[i]);
    228 
    229     /*
    230      * "=" operator
    231      */
    232     L<T1, T2> testList3;
    233     testList3 = testList;
     238    L<T1, T2> testList3(testList);
    234239
    235240    /* Check that all is correctly appended. */
     
    239244
    240245    /*
     246     * "=" operator
     247     */
     248    L<T1, T2> testList4;
     249    testList4 = testList;
     250
     251    /* Check that all is correctly appended. */
     252    RTTESTI_CHECK_RETV(testList4.size() == cTestItems);
     253    for (size_t i = 0; i < testList4.size(); ++i)
     254        RTTESTI_CHECK(testList4.at(i) == paTestData[i]);
     255
     256    /*
    241257     * Append list
    242258     */
    243     testList2.append(testList3);
     259    testList3.append(testList4);
    244260
    245261    /* Check that all is correctly appended. */
    246     RTTESTI_CHECK_RETV(testList2.size() == cTestItems * 2);
    247     for (size_t i = 0; i < testList2.size(); ++i)
    248         RTTESTI_CHECK(testList2.at(i) == paTestData[i % cTestItems]);
     262    RTTESTI_CHECK_RETV(testList3.size() == cTestItems * 2);
     263    for (size_t i = 0; i < testList3.size(); ++i)
     264        RTTESTI_CHECK(testList3.at(i) == paTestData[i % cTestItems]);
    249265
    250266    /*
    251267     * Prepend list
    252268     */
    253     testList2.prepend(testList3);
     269    testList3.prepend(testList4);
    254270
    255271    /* Check that all is correctly appended. */
    256     RTTESTI_CHECK_RETV(testList2.size() == cTestItems * 3);
    257     for (size_t i = 0; i < testList2.size(); ++i)
    258         RTTESTI_CHECK(testList2.at(i) == paTestData[i % cTestItems]);
     272    RTTESTI_CHECK_RETV(testList3.size() == cTestItems * 3);
     273    for (size_t i = 0; i < testList3.size(); ++i)
     274        RTTESTI_CHECK(testList3.at(i) == paTestData[i % cTestItems]);
    259275
    260276    /*
    261277     * "value" method
    262278     */
    263     for (size_t i = 0; i < testList2.size(); ++i)
    264         RTTESTI_CHECK(testList2.value(i)       == paTestData[i % cTestItems]);
    265     for (size_t i = 0; i < testList2.size(); ++i)
    266         RTTESTI_CHECK(testList2.value(i, T1()) == paTestData[i % cTestItems]);
    267     RTTESTI_CHECK(testList2.value(testList2.size() + 1) == T1());       /* Invalid index */
    268     RTTESTI_CHECK(testList2.value(testList2.size() + 1, T1()) == T1()); /* Invalid index */
     279    for (size_t i = 0; i < testList3.size(); ++i)
     280        RTTESTI_CHECK(testList3.value(i)       == paTestData[i % cTestItems]);
     281    for (size_t i = 0; i < testList3.size(); ++i)
     282        RTTESTI_CHECK(testList3.value(i, T1()) == paTestData[i % cTestItems]);
     283    RTTESTI_CHECK(testList3.value(testList3.size() + 1) == T1());       /* Invalid index */
     284    RTTESTI_CHECK(testList3.value(testList3.size() + 1, T1()) == T1()); /* Invalid index */
    269285
    270286    /*
     
    301317
    302318    /* Remove Range */
    303     testList2.removeRange(cTestItems, cTestItems * 2);
    304     RTTESTI_CHECK_RETV(testList2.size() == cTestItems * 2);
    305     for (size_t i = 0; i < testList2.size(); ++i)
    306         RTTESTI_CHECK(testList2.at(i) == paTestData[i % cTestItems]);
     319    testList3.removeRange(cTestItems, cTestItems * 2);
     320    RTTESTI_CHECK_RETV(testList3.size() == cTestItems * 2);
     321    for (size_t i = 0; i < testList3.size(); ++i)
     322        RTTESTI_CHECK(testList3.at(i) == paTestData[i % cTestItems]);
    307323
    308324    /* Remove the first half (reverse) */
     
    539555    uint8_t au8TestInts[s_cTestCount];
    540556    for (size_t i = 0; i < RT_ELEMENTS(au8TestInts); ++i)
    541         au8TestInts[i] = (uint8_t)RTRandU32Ex(0, UINT8_MAX);
     557        au8TestInts[i] = (uint8_t)RTRandU32Ex(1, UINT8_MAX);
    542558    test1<RTCList,   uint8_t, uint8_t, uint8_t>("ST: Native type", au8TestInts, RT_ELEMENTS(au8TestInts));
    543559    test1<RTCMTList, uint8_t, uint8_t, uint8_t>("MT: Native type", au8TestInts, RT_ELEMENTS(au8TestInts));
     
    545561    uint16_t au16TestInts[s_cTestCount];
    546562    for (size_t i = 0; i < RT_ELEMENTS(au16TestInts); ++i)
    547         au16TestInts[i] = (uint16_t)RTRandU32Ex(0, UINT16_MAX);
     563        au16TestInts[i] = (uint16_t)RTRandU32Ex(1, UINT16_MAX);
    548564    test1<RTCList,   uint16_t, uint16_t, uint16_t>("ST: Native type", au16TestInts, RT_ELEMENTS(au16TestInts));
    549565    test1<RTCMTList, uint16_t, uint16_t, uint16_t>("MT: Native type", au16TestInts, RT_ELEMENTS(au16TestInts));
     
    551567    uint32_t au32TestInts[s_cTestCount];
    552568    for (size_t i = 0; i < RT_ELEMENTS(au32TestInts); ++i)
    553         au32TestInts[i] = RTRandU32();
     569        au32TestInts[i] = RTRandU32Ex(1, UINT32_MAX);
    554570    test1<RTCList,   uint32_t, uint32_t, uint32_t>("ST: Native type", au32TestInts, RT_ELEMENTS(au32TestInts));
    555571    test1<RTCMTList, uint32_t, uint32_t, uint32_t>("MT: Native type", au32TestInts, RT_ELEMENTS(au32TestInts));
     
    560576    uint64_t au64TestInts[s_cTestCount];
    561577    for (size_t i = 0; i < RT_ELEMENTS(au64TestInts); ++i)
    562         au64TestInts[i] = RTRandU64();
     578        au64TestInts[i] = RTRandU64Ex(1, UINT64_MAX);
    563579    test1<RTCList,   uint64_t, uint64_t, uint64_t>("ST: Specialized type", au64TestInts, RT_ELEMENTS(au64TestInts));
    564580    test1<RTCMTList, uint64_t, uint64_t, uint64_t>("MT: Specialized type", au64TestInts, RT_ELEMENTS(au64TestInts));
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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