Changeset 4900 in CLRX


Ignore:
Timestamp:
Aug 16, 2019, 1:09:51 PM (5 weeks ago)
Author:
matszpk
Message:

CLRadeonExtender: ROCm: Add next testcases for ROCm MsgPack? parser - integers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CLRadeonExtender/trunk/tests/amdbin/ROCmMsgPack.cpp

    r4899 r4900  
    215215    {
    216216        MsgPackArrayParser arrParser(dataPtr, dataPtr + sizeof(tc10_1));
    217         assertValue("MsgPack0", "tc10_1.value0", uint64_t(int16_t(0xb37e)),
     217        assertValue("MsgPack0", "tc10_1.value0", uint64_t(0)+int16_t(0xb37e),
    218218                   arrParser.parseInteger(MSGPACK_WS_SIGNED));
    219219        assertValue("MsgPack0", "tc10_1.DataPtr", dataPtr, tc10_1 + sizeof(tc10_1));
     
    236236    }
    237237    // 32-bit integers
     238    const cxbyte tc11[6] = { 0x91, 0xce, 0xbe, 0x96, 0x41, 0x2e };
     239    dataPtr = tc11;
     240    {
     241        MsgPackArrayParser arrParser(dataPtr, dataPtr + sizeof(tc11));
     242        assertValue("MsgPack0", "tc11.value0", uint64_t(0x2e4196beU),
     243                   arrParser.parseInteger(MSGPACK_WS_UNSIGNED));
     244        assertValue("MsgPack0", "tc11.DataPtr", dataPtr, tc11 + sizeof(tc11));
     245    }
     246    const cxbyte tc11_1[6] = { 0x91, 0xce, 0xbe, 0x96, 0x42, 0xda };
     247    dataPtr = tc11_1;
     248    {
     249        MsgPackArrayParser arrParser(dataPtr, dataPtr + sizeof(tc11_1));
     250        assertValue("MsgPack0", "tc11_1.value0", uint64_t(0xda4296beU),
     251                   arrParser.parseInteger(MSGPACK_WS_UNSIGNED));
     252        assertValue("MsgPack0", "tc11_1.DataPtr", dataPtr, tc11_1 + sizeof(tc11_1));
     253    }
     254    for (cxuint i = 1; i <= 3; i++)
     255    {
     256        dataPtr = tc11_1;
     257        MsgPackArrayParser arrParser(dataPtr, dataPtr + sizeof(tc11_1)-i);
     258        assertCLRXException("MsgPack0", "tc11_2.Ex", "MsgPack: Can't parse integer value",
     259                    [&arrParser]() { arrParser.parseInteger(MSGPACK_WS_UNSIGNED); });
     260        assertValue("MsgPack0", "tc11_2.DataPtr", dataPtr, tc11_1 + 2);
     261    }
     262    const cxbyte tc12[6] = { 0x91, 0xd2, 0xbe, 0x96, 0x41, 0x2e };
     263    dataPtr = tc12;
     264    {
     265        MsgPackArrayParser arrParser(dataPtr, dataPtr + sizeof(tc12));
     266        assertValue("MsgPack0", "tc12.value0", uint64_t(0x2e4196beU),
     267                   arrParser.parseInteger(MSGPACK_WS_SIGNED));
     268        assertValue("MsgPack0", "tc12.DataPtr", dataPtr, tc12 + sizeof(tc12));
     269    }
     270    for (cxuint i = 1; i <= 3; i++)
     271    {
     272        dataPtr = tc12;
     273        MsgPackArrayParser arrParser(dataPtr, dataPtr + sizeof(tc12)-i);
     274        assertCLRXException("MsgPack0", "tc12_1.Ex", "MsgPack: Can't parse integer value",
     275                    [&arrParser]() { arrParser.parseInteger(MSGPACK_WS_SIGNED); });
     276        assertValue("MsgPack0", "tc12_1.DataPtr", dataPtr, tc12 + 2);
     277    }
     278    const cxbyte tc12_2[6] = { 0x91, 0xd2, 0xaf, 0x11, 0x79, 0xc1 };
     279    dataPtr = tc12_2;
     280    {
     281        MsgPackArrayParser arrParser(dataPtr, dataPtr + sizeof(tc12_2));
     282        assertValue("MsgPack0", "tc12_2.value0", uint64_t(0)+int32_t(0xc17911afU),
     283                   arrParser.parseInteger(MSGPACK_WS_SIGNED));
     284        assertValue("MsgPack0", "tc12_2.DataPtr", dataPtr, tc12_2 + sizeof(tc12_2));
     285    }
     286    dataPtr = tc12_2;
     287    {
     288        MsgPackArrayParser arrParser(dataPtr, dataPtr + sizeof(tc12_2));
     289        assertCLRXException("MsgPack0", "tc12_3.Ex",
     290                    "MsgPack: Negative value for unsigned integer",
     291                    [&arrParser]() { arrParser.parseInteger(MSGPACK_WS_UNSIGNED); });
     292        assertValue("MsgPack0", "tc12_3.DataPtr", dataPtr, tc12_2 + sizeof(tc12_2));
     293    }
     294    // 64-bit integers
     295    const cxbyte tc13[10] = { 0x91, 0xcf, 0x11, 0x3a, 0xf1, 0x4b, 0x13, 0xd9, 0x1e, 0x62 };
     296    dataPtr = tc13;
     297    {
     298        MsgPackArrayParser arrParser(dataPtr, dataPtr + sizeof(tc13));
     299        assertValue("MsgPack0", "tc13.value0", uint64_t(0x621ed9134bf13a11ULL),
     300                   arrParser.parseInteger(MSGPACK_WS_UNSIGNED));
     301        assertValue("MsgPack0", "tc13.DataPtr", dataPtr, tc13 + sizeof(tc13));
     302    }
     303    const cxbyte tc13_1[10] = { 0x91, 0xcf, 0x14, 0x3a, 0xf1,
     304                            0x4b, 0x13, 0xd9, 0x1e, 0xd7 };
     305    dataPtr = tc13_1;
     306    {
     307        MsgPackArrayParser arrParser(dataPtr, dataPtr + sizeof(tc13_1));
     308        assertValue("MsgPack0", "tc13_1.value0", uint64_t(0xd71ed9134bf13a14ULL),
     309                   arrParser.parseInteger(MSGPACK_WS_UNSIGNED));
     310        assertValue("MsgPack0", "tc13_1.DataPtr", dataPtr, tc13_1 + sizeof(tc13_1));
     311    }
     312    for (cxuint i = 1; i <= 7; i++)
     313    {
     314        dataPtr = tc13_1;
     315        MsgPackArrayParser arrParser(dataPtr, dataPtr + sizeof(tc13_1)-i);
     316        assertCLRXException("MsgPack0", "tc13_2.Ex", "MsgPack: Can't parse integer value",
     317                    [&arrParser]() { arrParser.parseInteger(MSGPACK_WS_UNSIGNED); });
     318        assertValue("MsgPack0", "tc13_2.DataPtr", dataPtr, tc13_1 + 2);
     319    }
     320    dataPtr = tc13_1;
     321    {
     322        MsgPackArrayParser arrParser(dataPtr, dataPtr + sizeof(tc13_1));
     323        assertCLRXException("MsgPack0", "tc13_3.Ex",
     324                    "MsgPack: Positive value out of range for signed integer",
     325                    [&arrParser]() { arrParser.parseInteger(MSGPACK_WS_SIGNED); });
     326        assertValue("MsgPack0", "tc13_3.DataPtr", dataPtr, tc13_1 + sizeof(tc13_1));
     327    }
     328    const cxbyte tc14[10] = { 0x91, 0xd3, 0x17, 0x3a, 0xf1, 0x4b, 0x13, 0xd9, 0x1e, 0x62 };
     329    dataPtr = tc14;
     330    {
     331        MsgPackArrayParser arrParser(dataPtr, dataPtr + sizeof(tc14));
     332        assertValue("MsgPack0", "tc14.value0", uint64_t(0x621ed9134bf13a17ULL),
     333                   arrParser.parseInteger(MSGPACK_WS_SIGNED));
     334        assertValue("MsgPack0", "tc14.DataPtr", dataPtr, tc14 + sizeof(tc14));
     335    }
     336    const cxbyte tc14_1[10] = { 0x91, 0xd3, 0x14, 0x3a, 0xf1,
     337                            0x4b, 0x13, 0xd9, 0x1e, 0xd7 };
     338    dataPtr = tc14_1;
     339    {
     340        MsgPackArrayParser arrParser(dataPtr, dataPtr + sizeof(tc14_1));
     341        assertValue("MsgPack0", "tc14_1.value0", uint64_t(0xd71ed9134bf13a14ULL),
     342                   arrParser.parseInteger(MSGPACK_WS_SIGNED));
     343        assertValue("MsgPack0", "tc14_1.DataPtr", dataPtr, tc14_1 + sizeof(tc14_1));
     344    }
     345    for (cxuint i = 1; i <= 7; i++)
     346    {
     347        dataPtr = tc14_1;
     348        MsgPackArrayParser arrParser(dataPtr, dataPtr + sizeof(tc14_1)-i);
     349        assertCLRXException("MsgPack0", "tc14_2.Ex", "MsgPack: Can't parse integer value",
     350                    [&arrParser]() { arrParser.parseInteger(MSGPACK_WS_SIGNED); });
     351        assertValue("MsgPack0", "tc14_2.DataPtr", dataPtr, tc14_1 + 2);
     352    }
    238353}
    239354
Note: See TracChangeset for help on using the changeset viewer.