void testObj::test<7>(void) { const Strategy::Params p(123, -0.11); ensure_equals("invalid timeout", p.timeout_, 123); ensure_equals("invalid delta", p.priDelta_, -0.11); }
~SDAllocationCheck() { ensure_equals(mMessage + " SDAllocationCheck", LLSD::allocationCount() - mAllocationAtStart, mExpectedAllocations); }
void testObj::test<1>(void) { ensure_equals("invalid READ value", Mode::READ, 1); }
void date_test_object_t::test<1>() { LLDate date(VALID_DATE); std::string expected_string; bool result; expected_string = VALID_DATE; ensure_equals("Valid Date failed" , expected_string, date.asString()); result = date.fromString(VALID_DATE_LEAP); expected_string = VALID_DATE_LEAP; ensure_equals("VALID_DATE_LEAP failed" , expected_string, date.asString()); result = date.fromString(VALID_DATE_HOUR_BOUNDARY); expected_string = VALID_DATE_HOUR_BOUNDARY; ensure_equals("VALID_DATE_HOUR_BOUNDARY failed" , expected_string, date.asString()); result = date.fromString(VALID_DATE_FRACTIONAL_SECS); expected_string = VALID_DATE_FRACTIONAL_SECS; ensure_equals("VALID_DATE_FRACTIONAL_SECS failed" , expected_string, date.asString()); result = date.fromString(INVALID_DATE_MISSING_YEAR); ensure_equals("INVALID_DATE_MISSING_YEAR should have failed" , result, false); result = date.fromString(INVALID_DATE_MISSING_MONTH); ensure_equals("INVALID_DATE_MISSING_MONTH should have failed" , result, false); result = date.fromString(INVALID_DATE_MISSING_DATE); ensure_equals("INVALID_DATE_MISSING_DATE should have failed" , result, false); result = date.fromString(INVALID_DATE_MISSING_T); ensure_equals("INVALID_DATE_MISSING_T should have failed" , result, false); result = date.fromString(INVALID_DATE_MISSING_HOUR); ensure_equals("INVALID_DATE_MISSING_HOUR should have failed" , result, false); result = date.fromString(INVALID_DATE_MISSING_MIN); ensure_equals("INVALID_DATE_MISSING_MIN should have failed" , result, false); result = date.fromString(INVALID_DATE_MISSING_SEC); ensure_equals("INVALID_DATE_MISSING_SEC should have failed" , result, false); result = date.fromString(INVALID_DATE_MISSING_Z); ensure_equals("INVALID_DATE_MISSING_Z should have failed" , result, false); result = date.fromString(INVALID_DATE_EMPTY); ensure_equals("INVALID_DATE_EMPTY should have failed" , result, false); }
~SDCleanupCheck() { ensure_equals("SDCleanupCheck", LLSD::outstandingCount(), mOutstandingAtStart); }
void testObj::test<5>(void) { ensure_equals("invalid concatenataion", ce_.cc("a", "b", "c", "d", "e", "f"), "abcdef"); }
void URITestObject::test<18>() { LLURI u("GIS:///app/login?first_name=Testert4&last_name=Tester&web_login_key=test"); // if GIS is the scheme, LLURI should parse /app/login as path, with no authority ensure_equals("scheme", u.scheme(), "GIS"); ensure_equals("authority", u.authority(), ""); ensure_equals("path", u.path(), "/app/login"); ensure_equals("pathmap", u.pathArray()[0].asString(), "app"); ensure_equals("pathmap", u.pathArray()[1].asString(), "login"); ensure_equals("query", u.query(), "first_name=Testert4&last_name=Tester&web_login_key=test"); ensure_equals("query map element", u.queryMap()["last_name"].asString(), "Tester"); u = LLURI("GIS://Da Boom/128/128/128"); // if GIS is the scheme, LLURI should parse /128/128/128 as path, with Da Boom as authority ensure_equals("scheme", u.scheme(), "GIS"); ensure_equals("authority", u.authority(), "Da Boom"); ensure_equals("path", u.path(), "/128/128/128"); ensure_equals("pathmap", u.pathArray()[0].asString(), "128"); ensure_equals("pathmap", u.pathArray()[1].asString(), "128"); ensure_equals("pathmap", u.pathArray()[2].asString(), "128"); ensure_equals("query", u.query(), ""); }
void testobject::test<2>() { set_test_name("Check traff types"); TARIFF_DATA td("test"); td.tariffConf.fee = 1; td.tariffConf.free = 2; td.tariffConf.traffType = TARIFF::TRAFF_UP; td.tariffConf.passiveCost = 4; td.dirPrice[0].mDay = 30; td.dirPrice[0].hDay = 9; td.dirPrice[0].mNight = 30; td.dirPrice[0].hNight = 21; td.dirPrice[0].priceDayA = 0; td.dirPrice[0].priceDayB = 1; td.dirPrice[0].priceNightA = 2; td.dirPrice[0].priceNightB = 3; td.dirPrice[0].threshold = 4; td.dirPrice[0].singlePrice = 0; td.dirPrice[0].noDiscount = 0; TARIFF_IMPL tariff(td); ensure("traffType = TRAFF_UP", tariff.GetTraffType() == TARIFF::TRAFF_UP); ensure_equals("traffByType(6, 0) = 6 for UP", tariff.GetTraffByType(6, 0), 6); ensure_equals("traffByType(5, 1) = 5 for UP", tariff.GetTraffByType(5, 1), 5); ensure_equals("traffByType(4, 2) = 4 for UP", tariff.GetTraffByType(4, 2), 4); ensure_equals("traffByType(3, 3) = 3 for UP", tariff.GetTraffByType(3, 3), 3); ensure_equals("traffByType(2, 4) = 2 for UP", tariff.GetTraffByType(2, 4), 2); ensure_equals("traffByType(1, 5) = 1 for UP", tariff.GetTraffByType(1, 5), 1); ensure_equals("traffByType(0, 6) = 0 for UP", tariff.GetTraffByType(0, 6), 0); td.tariffConf.traffType = TARIFF::TRAFF_DOWN; tariff = td; ensure("traffType = TRAFF_DOWN", tariff.GetTraffType() == TARIFF::TRAFF_DOWN); ensure_equals("traffByType(6, 0) = 0 for DOWN", tariff.GetTraffByType(6, 0), 0); ensure_equals("traffByType(5, 1) = 1 for DOWN", tariff.GetTraffByType(5, 1), 1); ensure_equals("traffByType(4, 2) = 2 for DOWN", tariff.GetTraffByType(4, 2), 2); ensure_equals("traffByType(3, 3) = 3 for DOWN", tariff.GetTraffByType(3, 3), 3); ensure_equals("traffByType(2, 4) = 4 for DOWN", tariff.GetTraffByType(2, 4), 4); ensure_equals("traffByType(1, 5) = 5 for DOWN", tariff.GetTraffByType(1, 5), 5); ensure_equals("traffByType(0, 6) = 6 for DOWN", tariff.GetTraffByType(0, 6), 6); td.tariffConf.traffType = TARIFF::TRAFF_MAX; tariff = td; ensure("traffType = TRAFF_MAX", tariff.GetTraffType() == TARIFF::TRAFF_MAX); ensure_equals("traffByType(6, 0) = 6 for MAX", tariff.GetTraffByType(6, 0), 6); ensure_equals("traffByType(5, 1) = 5 for MAX", tariff.GetTraffByType(5, 1), 5); ensure_equals("traffByType(4, 2) = 4 for MAX", tariff.GetTraffByType(4, 2), 4); ensure_equals("traffByType(3, 3) = 3 for MAX", tariff.GetTraffByType(3, 3), 3); ensure_equals("traffByType(2, 4) = 4 for MAX", tariff.GetTraffByType(2, 4), 4); ensure_equals("traffByType(1, 5) = 5 for MAX", tariff.GetTraffByType(1, 5), 5); ensure_equals("traffByType(0, 6) = 6 for MAX", tariff.GetTraffByType(0, 6), 6); td.tariffConf.traffType = TARIFF::TRAFF_UP_DOWN; tariff = td; ensure("traffType = TRAFF_UP_DOWN", tariff.GetTraffType() == TARIFF::TRAFF_UP_DOWN); ensure_equals("traffByType(6, 0) = 6 for UP_DOWN", tariff.GetTraffByType(6, 0), 6); ensure_equals("traffByType(5, 1) = 6 for UP_DOWN", tariff.GetTraffByType(5, 1), 6); ensure_equals("traffByType(4, 2) = 6 for UP_DOWN", tariff.GetTraffByType(4, 2), 6); ensure_equals("traffByType(3, 3) = 6 for UP_DOWN", tariff.GetTraffByType(3, 3), 6); ensure_equals("traffByType(2, 4) = 6 for UP_DOWN", tariff.GetTraffByType(2, 4), 6); ensure_equals("traffByType(1, 5) = 6 for UP_DOWN", tariff.GetTraffByType(1, 5), 6); ensure_equals("traffByType(0, 6) = 6 for UP_DOWN", tariff.GetTraffByType(0, 6), 6); }
void sd_object::test<16>() { std::string val = "[f,t,0,1,{'foo':t,'bar':f}]"; std::istringstream istr; istr.str(val); LLSD sd; LLSDSerialize::fromNotation(sd, istr, val.size()); ensure_equals("parsed type", sd.type(), LLSD::TypeArray); ensure_equals("parsed size", sd.size(), 5); ensure_equals("element 0 false", sd[0].asBoolean(), false); ensure_equals("element 1 true", sd[1].asBoolean(), true); ensure_equals("element 2 false", sd[2].asBoolean(), false); ensure_equals("element 3 true", sd[3].asBoolean(), true); LLSD map = sd[4]; ensure_equals("element 4 type", map.type(), LLSD::TypeMap); ensure_equals("map foo type", map["foo"].type(), LLSD::TypeBoolean); ensure_equals("map foo value", map["foo"].asBoolean(), true); ensure_equals("map bar type", map["bar"].type(), LLSD::TypeBoolean); ensure_equals("map bar value", map["bar"].asBoolean(), false); }
void datapacker_test_object_t::test<2>() { U8 packbuf[1024]; char str[] = "SecondLife is virtual World\0"; char strBinary[] = "SecondLife is virtual World"; char strBinaryFixed[] = "Fixed Data"; S32 sizeBinaryFixed = sizeof(strBinaryFixed); U8 valU8 = 'C'; U16 valU16 = 0xFFFF; U32 valU32 = 0xFFFFFFFF; S32 valS32 = -94967295; F32 valF32 = 4354355.44f ; LLColor4 llcol4(3.3f, 0, 4.4f, 5.5f); LLColor4U llcol4u(3, 128, 24, 33); LLVector2 llvec2(333.33f, 444.44f); LLVector3 llvec3(333.33f, 444.44f, 555.55f); LLVector4 llvec4(333.33f, 444.44f, 555.55f, 666.66f); LLUUID uuid; std::string unpkstr; char unpkstrBinary[256]; char unpkstrBinaryFixed[256]; S32 unpksizeBinary; U8 unpkvalU8; U16 unpkvalU16; U32 unpkvalU32; S32 unpkvalS32; F32 unpkvalF32; LLColor4 unpkllcol4; LLColor4U unpkllcol4u; LLVector2 unpkllvec2; LLVector3 unpkllvec3; LLVector4 unpkllvec4; LLUUID unpkuuid; LLDataPackerBinaryBuffer lldp(packbuf,1024); lldp.packString(str , "linden_lab_str"); lldp.packBinaryData((U8*)strBinary, sizeof(strBinary), "linden_lab_bd"); lldp.packBinaryDataFixed((U8*)strBinaryFixed, sizeBinaryFixed, "linden_lab_bdf"); lldp.packU8(valU8,"linden_lab_u8"); lldp.packU16(valU16,"linden_lab_u16"); lldp.packU32(valU32, "linden_lab_u32"); lldp.packS32(valS32, "linden_lab_s32"); lldp.packF32(valF32, "linden_lab_f32"); lldp.packColor4(llcol4, "linden_lab_col4"); lldp.packColor4U(llcol4u, "linden_lab_col4u"); lldp.packVector2(llvec2, "linden_lab_vec2"); lldp.packVector3(llvec3, "linden_lab_vec3"); lldp.packVector4(llvec4, "linden_lab_vec4"); uuid.generate(); lldp.packUUID(uuid, "linden_lab_uuid"); S32 cur_size = lldp.getCurrentSize(); LLDataPackerBinaryBuffer lldp1(packbuf, cur_size); lldp1.unpackString(unpkstr , "linden_lab_str"); lldp1.unpackBinaryData((U8*)unpkstrBinary, unpksizeBinary, "linden_lab_bd"); lldp1.unpackBinaryDataFixed((U8*)unpkstrBinaryFixed, sizeBinaryFixed, "linden_lab_bdf"); lldp1.unpackU8(unpkvalU8,"linden_lab_u8"); lldp1.unpackU16(unpkvalU16,"linden_lab_u16"); lldp1.unpackU32(unpkvalU32, "linden_lab_u32"); lldp1.unpackS32(unpkvalS32, "linden_lab_s32"); lldp1.unpackF32(unpkvalF32, "linden_lab_f32"); lldp1.unpackColor4(unpkllcol4, "linden_lab_col4"); lldp1.unpackColor4U(unpkllcol4u, "linden_lab_col4u"); lldp1.unpackVector2(unpkllvec2, "linden_lab_vec2"); lldp1.unpackVector3(unpkllvec3, "linden_lab_vec3"); lldp1.unpackVector4(unpkllvec4, "linden_lab_vec4"); lldp1.unpackUUID(unpkuuid, "linden_lab_uuid"); ensure("LLDataPackerBinaryBuffer::packString failed", strcmp(str, unpkstr.c_str()) == 0); ensure("LLDataPackerBinaryBuffer::packBinaryData failed", strcmp(strBinary, unpkstrBinary) == 0); ensure("LLDataPackerBinaryBuffer::packBinaryDataFixed failed", strcmp(strBinaryFixed, unpkstrBinaryFixed) == 0); ensure_equals("LLDataPackerBinaryBuffer::packU8 failed", valU8, unpkvalU8); ensure_equals("LLDataPackerBinaryBuffer::packU16 failed", valU16, unpkvalU16); ensure_equals("LLDataPackerBinaryBuffer::packU32 failed", valU32, unpkvalU32); ensure_equals("LLDataPackerBinaryBuffer::packS32 failed", valS32, unpkvalS32); ensure("LLDataPackerBinaryBuffer::packF32 failed", is_approx_equal(valF32, unpkvalF32)); ensure_equals("LLDataPackerBinaryBuffer::packColor4 failed", llcol4, unpkllcol4); ensure_equals("LLDataPackerBinaryBuffer::packColor4U failed", llcol4u, unpkllcol4u); ensure_equals("LLDataPackerBinaryBuffer::packVector2 failed", llvec2, unpkllvec2); ensure_equals("LLDataPackerBinaryBuffer::packVector3 failed", llvec3, unpkllvec3); ensure_equals("LLDataPackerBinaryBuffer::packVector4 failed", llvec4, unpkllvec4); ensure_equals("LLDataPackerBinaryBuffer::packUUID failed", uuid, unpkuuid); }
void testobject::test<6>() { set_test_name("Check normal interval prices for day-night inversion"); TARIFF_DATA td("test"); td.tariffConf.fee = 1; td.tariffConf.free = 2; td.tariffConf.traffType = TARIFF::TRAFF_UP_DOWN; td.tariffConf.passiveCost = 4; td.dirPrice[0].mDay = 30; td.dirPrice[0].hDay = 21; td.dirPrice[0].mNight = 30; td.dirPrice[0].hNight = 9; td.dirPrice[0].priceDayA = 0; td.dirPrice[0].priceDayB = 1; td.dirPrice[0].priceNightA = 2; td.dirPrice[0].priceNightB = 3; td.dirPrice[0].threshold = 4; td.dirPrice[0].singlePrice = 0; td.dirPrice[0].noDiscount = 0; TARIFF_IMPL tariff(td); ensure_equals("0000 == 0", tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286461245), 2); // Near 17:30, 0 < 4 NA ensure_equals("0001 == 0", tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286461245), 3); // Near 17:30, 6 > 4 NB ensure_equals("0010 == 0", tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286479245), 0); // Near 22:30, 0 < 4 DA ensure_equals("0011 == 0", tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286479245), 1); // Near 22:30, 6 > 4 DB td.dirPrice[0].singlePrice = 1; tariff = td; ensure_equals("0100 == 0", tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286461245), 0); // Near 17:30, 0 < 4 DA (ignore night) ensure_equals("0101 == 0", tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286461245), 1); // Near 17:30, 6 > 4 DB (ignore night) ensure_equals("0110 == 0", tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286479245), 0); // Near 22:30, 0 < 4 DA (ignore night) ensure_equals("0111 == 0", tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286479245), 1); // Near 22:30, 6 > 4 DB (ignore night) td.dirPrice[0].singlePrice = 0; td.dirPrice[0].noDiscount = 1; tariff = td; ensure_equals("1000 == 0", tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286461245), 2); // Near 17:30, 0 < 4 NA ensure_equals("1001 == 0", tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286461245), 2); // Near 17:30, 6 > 4 NA ensure_equals("1010 == 0", tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286479245), 0); // Near 22:30, 0 < 4 DA ensure_equals("1011 == 0", tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286479245), 0); // Near 22:30, 6 > 4 DA td.dirPrice[0].singlePrice = 1; td.dirPrice[0].noDiscount = 1; tariff = td; ensure_equals("1100 == 0", tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286461245), 0); // Near 17:30, 0 < 4 DA (ignore night) ensure_equals("1101 == 0", tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286461245), 0); // Near 17:30, 6 > 4 DA (ignore night) ensure_equals("1110 == 0", tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286479245), 0); // Near 22:30, 0 < 4 DA (ignore night) ensure_equals("1111 == 0", tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286479245), 0); // Near 22:30, 6 > 4 DA (ignore night) }
void datapacker_test_object_t::test<14>() { char str[] = "SecondLife is virtual World\0"; char strBinary[] = "SecondLife is virtual World"; char strBinaryFixed[] = "Fixed Data"; S32 sizeBinaryFixed = sizeof(strBinaryFixed); U8 valU8 = 'C'; U16 valU16 = 0xFFFF; U32 valU32 = 0xFFFFFFFF; S32 valS32 = -94967295; F32 valF32 = 4354355.44f ; LLColor4 llcol4(3.3f, 0, 4.4f, 5.5f); LLColor4U llcol4u(3, 128, 24, 33); LLVector2 llvec2(3333333.33f, 444.333344f); LLVector3 llvec3(3323233.33f, 444.4324f, 555.553232f); LLVector4 llvec4(333.33233f, 444.4323234f, 55323225.55f, 6323236.66f); LLUUID uuid; std::string unpkstr; char unpkstrBinary[256]; char unpkstrBinaryFixed[256]; S32 unpksizeBinary; U8 unpkvalU8; U16 unpkvalU16; U32 unpkvalU32; S32 unpkvalS32; F32 unpkvalF32; LLColor4 unpkllcol4; LLColor4U unpkllcol4u; LLVector2 unpkllvec2; LLVector3 unpkllvec3; LLVector4 unpkllvec4; LLUUID unpkuuid; std::ostringstream ostr; LLDataPackerAsciiFile lldp(ostr,2); lldp.packString(str , "linden_lab_str"); lldp.packBinaryData((U8*)strBinary, sizeof(strBinary), "linden_lab_bd"); lldp.packBinaryDataFixed((U8*)strBinaryFixed, sizeBinaryFixed, "linden_lab_bdf"); lldp.packU8(valU8,"linden_lab_u8"); lldp.packU16(valU16,"linden_lab_u16"); lldp.packU32(valU32, "linden_lab_u32"); lldp.packS32(valS32, "linden_lab_s32"); lldp.packF32(valF32, "linden_lab_f32"); lldp.packColor4(llcol4, "linden_lab_col4"); lldp.packColor4U(llcol4u, "linden_lab_col4u"); lldp.packVector2(llvec2, "linden_lab_vec2"); lldp.packVector3(llvec3, "linden_lab_vec3"); lldp.packVector4(llvec4, "linden_lab_vec4"); uuid.generate(); lldp.packUUID(uuid, "linden_lab_uuid"); std::istringstream istr(ostr.str()); LLDataPackerAsciiFile lldp1(istr,2); lldp1.unpackString(unpkstr , "linden_lab_str"); lldp1.unpackBinaryData((U8*)unpkstrBinary, unpksizeBinary, "linden_lab_bd"); lldp1.unpackBinaryDataFixed((U8*)unpkstrBinaryFixed, sizeBinaryFixed, "linden_lab_bdf"); lldp1.unpackU8(unpkvalU8,"linden_lab_u8"); lldp1.unpackU16(unpkvalU16,"linden_lab_u16"); lldp1.unpackU32(unpkvalU32, "linden_lab_u32"); lldp1.unpackS32(unpkvalS32, "linden_lab_s32"); lldp1.unpackF32(unpkvalF32, "linden_lab_f32"); lldp1.unpackColor4(unpkllcol4, "linden_lab_col4"); lldp1.unpackColor4U(unpkllcol4u, "linden_lab_col4u"); lldp1.unpackVector2(unpkllvec2, "linden_lab_vec2"); lldp1.unpackVector3(unpkllvec3, "linden_lab_vec3"); lldp1.unpackVector4(unpkllvec4, "linden_lab_vec4"); lldp1.unpackUUID(unpkuuid, "linden_lab_uuid"); ensure("LLDataPackerAsciiFile::packString (iostring) failed", strcmp(str, unpkstr.c_str()) == 0); ensure("LLDataPackerAsciiFile::packBinaryData (iostring) failed", strcmp(strBinary, unpkstrBinary) == 0); ensure("LLDataPackerAsciiFile::packBinaryDataFixed (iostring) failed", strcmp(strBinaryFixed, unpkstrBinaryFixed) == 0); ensure_equals("LLDataPackerAsciiFile::packU8 (iostring) failed", valU8, unpkvalU8); ensure_equals("LLDataPackerAsciiFile::packU16 (iostring) failed", valU16, unpkvalU16); ensure_equals("LLDataPackerAsciiFile::packU32 (iostring) failed", valU32, unpkvalU32); ensure_equals("LLDataPackerAsciiFile::packS32 (iostring) failed", valS32, unpkvalS32); ensure("LLDataPackerAsciiFile::packF32 (iostring) failed", is_approx_equal(valF32, unpkvalF32)); ensure_equals("LLDataPackerAsciiFile::packColor4 (iostring) failed", llcol4, unpkllcol4); ensure_equals("LLDataPackerAsciiFile::packColor4U (iostring) failed", llcol4u, unpkllcol4u); ensure_equals("LLDataPackerAsciiFile::packVector2 (iostring) failed", llvec2, unpkllvec2); ensure_equals("LLDataPackerAsciiFile::packVector3 (iostring) failed", llvec3, unpkllvec3); ensure_equals("LLDataPackerAsciiFile::packVector4 (iostring) failed", llvec4, unpkllvec4); ensure_equals("LLDataPackerAsciiFile::packUUID (iostring) failed", uuid, unpkuuid); }
void datapacker_test_object_t::test<12>() { char str[] = "SecondLife is virtual World\0"; char strBinary[] = "SecondLife is virtual World"; char strBinaryFixed[] = "Fixed Data"; S32 sizeBinaryFixed = sizeof(strBinaryFixed); U8 valU8 = 'C'; U16 valU16 = 0xFFFF; U32 valU32 = 0xFFFFFFFF; S32 valS32 = -94967295; F32 valF32 = 4354355.44f ; LLColor4 llcol4(3.3f, 0, 4.4f, 5.5f); LLColor4U llcol4u(3, 128, 24, 33); LLVector2 llvec2(333.33f, 444.44f); LLVector3 llvec3(333.33f, 444.44f, 555.55f); LLVector4 llvec4(333.33f, 444.44f, 555.55f, 666.66f); LLUUID uuid; std::string unpkstr; char unpkstrBinary[256]; char unpkstrBinaryFixed[256]; S32 unpksizeBinary; U8 unpkvalU8; U16 unpkvalU16; U32 unpkvalU32; S32 unpkvalS32; F32 unpkvalF32; LLColor4 unpkllcol4; LLColor4U unpkllcol4u; LLVector2 unpkllvec2; LLVector3 unpkllvec3; LLVector4 unpkllvec4; LLUUID unpkuuid; LLFILE* fp = LLFile::fopen(TEST_FILE_NAME,"w+"); if(!fp) { LL_ERRS() << "File couldnt be open" <<LL_ENDL; return; } LLDataPackerAsciiFile lldp(fp,2); lldp.packString(str , "linden_lab_str"); lldp.packBinaryData((U8*)strBinary, sizeof(strBinary), "linden_lab_bd"); lldp.packBinaryDataFixed((U8*)strBinaryFixed, sizeBinaryFixed, "linden_lab_bdf"); lldp.packU8(valU8,"linden_lab_u8"); lldp.packU16(valU16,"linden_lab_u16"); lldp.packU32(valU32, "linden_lab_u32"); lldp.packS32(valS32, "linden_lab_s32"); lldp.packF32(valF32, "linden_lab_f32"); lldp.packColor4(llcol4, "linden_lab_col4"); lldp.packColor4U(llcol4u, "linden_lab_col4u"); lldp.packVector2(llvec2, "linden_lab_vec2"); lldp.packVector3(llvec3, "linden_lab_vec3"); lldp.packVector4(llvec4, "linden_lab_vec4"); uuid.generate(); lldp.packUUID(uuid, "linden_lab_uuid"); fflush(fp); fseek(fp,0,SEEK_SET); LLDataPackerAsciiFile lldp1(fp,2); lldp1.unpackString(unpkstr , "linden_lab_str"); lldp1.unpackBinaryData((U8*)unpkstrBinary, unpksizeBinary, "linden_lab_bd"); lldp1.unpackBinaryDataFixed((U8*)unpkstrBinaryFixed, sizeBinaryFixed, "linden_lab_bdf"); lldp1.unpackU8(unpkvalU8,"linden_lab_u8"); lldp1.unpackU16(unpkvalU16,"linden_lab_u16"); lldp1.unpackU32(unpkvalU32, "linden_lab_u32"); lldp1.unpackS32(unpkvalS32, "linden_lab_s32"); lldp1.unpackF32(unpkvalF32, "linden_lab_f32"); lldp1.unpackColor4(unpkllcol4, "linden_lab_col4"); lldp1.unpackColor4U(unpkllcol4u, "linden_lab_col4u"); lldp1.unpackVector2(unpkllvec2, "linden_lab_vec2"); lldp1.unpackVector3(unpkllvec3, "linden_lab_vec3"); lldp1.unpackVector4(unpkllvec4, "linden_lab_vec4"); lldp1.unpackUUID(unpkuuid, "linden_lab_uuid"); fclose(fp); ensure("LLDataPackerAsciiFile::packString failed", strcmp(str, unpkstr.c_str()) == 0); ensure("LLDataPackerAsciiFile::packBinaryData failed", strcmp(strBinary, unpkstrBinary) == 0); ensure("LLDataPackerAsciiFile::packBinaryDataFixed failed", strcmp(strBinaryFixed, unpkstrBinaryFixed) == 0); ensure_equals("LLDataPackerAsciiFile::packU8 failed", valU8, unpkvalU8); ensure_equals("LLDataPackerAsciiFile::packU16 failed", valU16, unpkvalU16); ensure_equals("LLDataPackerAsciiFile::packU32 failed", valU32, unpkvalU32); ensure_equals("LLDataPackerAsciiFile::packS32 failed", valS32, unpkvalS32); ensure("LLDataPackerAsciiFile::packF32 failed", is_approx_equal(valF32, unpkvalF32)); ensure_equals("LLDataPackerAsciiFile::packColor4 failed", llcol4, unpkllcol4); ensure_equals("LLDataPackerAsciiFile::packColor4U failed", llcol4u, unpkllcol4u); ensure_equals("LLDataPackerAsciiFile::packVector2 failed", llvec2, unpkllvec2); ensure_equals("LLDataPackerAsciiFile::packVector3 failed", llvec3, unpkllvec3); ensure_equals("LLDataPackerAsciiFile::packVector4 failed", llvec4, unpkllvec4); ensure_equals("LLDataPackerAsciiFile::packUUID failed", uuid, unpkuuid); }
void testObj::test<13>(void) { Iter it(data2_); ConstIter cit(it); ensure_equals("iterators point ot different places", *it, *cit); }
void testObj::test<6>(void) { ensure_equals("pre-condition failed", params_.heartbeats_, 0); impl_.heartbeat(42u); ensure_equals("call not passed", params_.heartbeats_, 1); }
void testObj::test<2>(void) { ensure_equals("mutex not locked", pthread_mutex_trylock(&g_testMutex), EBUSY); }
void testObj::test<2>(void) { ensure_equals("invalid concatenataion", ce_.cc("a", "b", "c"), "abc"); }
void deps_object::test<1>() { StringDeps deps; StringList empty; // The quick brown fox jumps over the lazy yellow dog. // (note, "The" and "the" are distinct, else this test wouldn't work) deps.add("lazy"); ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy"))); deps.add("jumps"); ensure("found lazy", deps.get("lazy")); ensure("not found dog.", ! deps.get("dog.")); // NOTE: Maybe it's overkill to test each of these intermediate // results before all the interdependencies have been specified. My // thought is simply that if the order changes, I'd like to know why. // A change to the implementation of boost::topological_sort() would // be an acceptable reason, and you can simply update the expected // test output. ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("jumps"))); deps.add("The", 0, empty, list_of("fox")("dog.")); // Test key accessors ensure("empty before deps for missing key", is_empty(deps.get_before_range("bogus"))); ensure("empty before deps for jumps", is_empty(deps.get_before_range("jumps"))); ensure_equals(instance_from_range< std::set<std::string> >(deps.get_before_range("The")), make< std::set<std::string> >(list_of("dog.")("fox"))); // resume building dependencies ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("jumps")("The"))); deps.add("the", 0, list_of("The")); ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("jumps")("The")("the"))); deps.add("fox", 0, list_of("The"), list_of("jumps")); ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("The")("the")("fox")("jumps"))); deps.add("the", 0, list_of("The")); // same, see if cache works ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("The")("the")("fox")("jumps"))); deps.add("jumps", 0, empty, list_of("over")); // update jumps deps ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("The")("the")("fox")("jumps"))); /*==========================================================================*| // It drives me nuts that this test doesn't work in the test // framework, because -- for reasons unknown -- running the test // framework on Mac OS X 10.5 Leopard and Windows XP Pro, the catch // clause below doesn't catch the exception. Something about the TUT // test framework?!? The identical code works fine in a standalone // test program. Commenting out the test for now, in hopes that our // real builds will be able to catch Cycle exceptions... try { // We've already specified fox -> jumps and jumps -> over. Try an // impossible constraint. deps.add("over", 0, empty, list_of("fox")); } catch (const StringDeps::Cycle& e) { std::cout << "Cycle detected: " << e.what() << '\n'; // It's legal to add() an impossible constraint because we don't // detect the cycle until sort(). So sort() can't know the minimum set // of nodes to remove to make the StringDeps object valid again. // Therefore we must break the cycle by hand. deps.remove("over"); } |*==========================================================================*/ deps.add("dog.", 0, list_of("yellow")("lazy")); ensure_equals(instance_from_range< std::set<std::string> >(deps.get_after_range("dog.")), make< std::set<std::string> >(list_of("lazy")("yellow"))); ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("The")("the")("fox")("jumps")("dog."))); deps.add("quick", 0, list_of("The"), list_of("fox")("brown")); ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("The")("the")("quick")("fox")("jumps")("dog."))); deps.add("over", 0, list_of("jumps"), list_of("yellow")("the")); ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("The")("quick")("fox")("jumps")("over")("the")("dog."))); deps.add("yellow", 0, list_of("the"), list_of("lazy")); ensure_equals(sorted_keys(deps), make<StringList>(list_of("The")("quick")("fox")("jumps")("over")("the")("yellow")("lazy")("dog."))); deps.add("brown"); // By now the dependencies are pretty well in place. A change to THIS // order should be viewed with suspicion. ensure_equals(sorted_keys(deps), make<StringList>(list_of("The")("quick")("brown")("fox")("jumps")("over")("the")("yellow")("lazy")("dog."))); StringList keys(make<StringList>(list_of("The")("brown")("dog.")("fox")("jumps")("lazy")("over")("quick")("the")("yellow"))); ensure_equals(instance_from_range<StringList>(deps.get_key_range()), keys); #if (! defined(__GNUC__)) || (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ > 3) // This is the succinct way, works on modern compilers ensure_equals(instance_from_range<StringList>(make_transform_range(deps.get_range(), extract_key)), keys); #else // gcc 3.3 StringDeps::range got_range(deps.get_range()); StringDeps::iterator kni = got_range.begin(), knend = got_range.end(); StringList::iterator ki = keys.begin(), kend = keys.end(); for ( ; kni != knend && ki != kend; ++kni, ++ki) { ensure_equals(kni->first, *ki); } ensure("get_range() returns proper length", kni == knend && ki == kend); #endif // gcc 3.3 // blow off get_node_range() because they're all LLDependenciesEmpty instances }
void stringize_object::test<2>() { ensure_equals(STRINGIZE("c is " << c), "c is c"); ensure_equals(STRINGIZE(std::setprecision(4) << d), "3.142"); }
void deps_object::test<2>() { typedef LLDependencies<std::string, int> NameIndexDeps; NameIndexDeps nideps; const NameIndexDeps& const_nideps(nideps); nideps.add("def", 2, list_of("ghi")); nideps.add("ghi", 3); nideps.add("abc", 1, list_of("def")); NameIndexDeps::range range(nideps.get_range()); ensure_equals(range.begin()->first, "abc"); ensure_equals(range.begin()->second, 1); range.begin()->second = 0; range.begin()->second = 1; NameIndexDeps::const_range const_range(const_nideps.get_range()); NameIndexDeps::const_iterator const_iterator(const_range.begin()); ++const_iterator; ensure_equals(const_iterator->first, "def"); ensure_equals(const_iterator->second, 2); // NameIndexDeps::node_range node_range(nideps.get_node_range()); // ensure_equals(instance_from_range<std::vector<int> >(node_range), make< std::vector<int> >(list_of(1)(2)(3))); // *node_range.begin() = 0; // *node_range.begin() = 1; NameIndexDeps::const_node_range const_node_range(const_nideps.get_node_range()); ensure_equals(instance_from_range<std::vector<int> >(const_node_range), make< std::vector<int> >(list_of(1)(2)(3))); NameIndexDeps::const_key_range const_key_range(const_nideps.get_key_range()); ensure_equals(instance_from_range<StringList>(const_key_range), make<StringList>(list_of("abc")("def")("ghi"))); NameIndexDeps::sorted_range sorted(const_nideps.sort()); NameIndexDeps::sorted_iterator sortiter(sorted.begin()); ensure_equals(sortiter->first, "ghi"); ensure_equals(sortiter->second, 3); // test all iterator-flavored versions of get_after_range() StringList def(make<StringList>(list_of("def"))); ensure("empty abc before list", is_empty(nideps.get_before_range(nideps.get_range().begin()))); ensure_equals(instance_from_range<StringList>(nideps.get_after_range(nideps.get_range().begin())), def); ensure_equals(instance_from_range<StringList>(const_nideps.get_after_range(const_nideps.get_range().begin())), def); // ensure_equals(instance_from_range<StringList>(nideps.get_after_range(nideps.get_node_range().begin())), // def); ensure_equals(instance_from_range<StringList>(const_nideps.get_after_range(const_nideps.get_node_range().begin())), def); ensure_equals(instance_from_range<StringList>(nideps.get_after_range(nideps.get_key_range().begin())), def); // advance from "ghi" to "def", which must come after "ghi" ++sortiter; ensure_equals(instance_from_range<StringList>(const_nideps.get_after_range(sortiter)), make<StringList>(list_of("ghi"))); }
void date_test_object_t::test<4>() { LLDate date1(VALID_DATE); LLDate date2(date1); ensure_equals("LLDate(const LLDate& date) constructor failed", date1.asString(), date2.asString()); }
void checkIsValid(Geometry& geom, bool expected) { IsValidOp validator(&geom); bool isValid = validator.isValid(); ensure_equals(isValid, expected); }
void SDTestObject::test<8>() // Test construction of various scalar types from LLSD. // Test both construction and initialization forms. // These should invoke the right conversion without it being // mentioned explicitly. The few exceptions are marked SAD. { SDCleanupCheck check; LLSD v(" 42.375"); bool b1(v); ensure_equals("contruct bool", b1, true); bool b2 = v; ensure_equals("initialize bool", b2, true); int i1(v); ensure_equals("contruct int", i1, 42); int i2 = v; ensure_equals("initialize int", i2, 42); double d1(v); ensure_equals("contruct double", d1, 42.375); double d2 = v; ensure_equals("initialize double", d2, 42.375); std::string s1(v); std::string s2 = v; ensure_equals("contruct string", s1, " 42.375"); ensure_equals("initialize string", s2, " 42.375"); std::string t1(v); std::string t2 = v.asString(); // SAD ensure_equals("contruct std::string", t1, " 42.375"); ensure_equals("initialize std::string", t2, " 42.375"); std::string uuidStr = "b1e50c2b-b627-4d23-8a86-a65d97b6319b"; v = uuidStr; LLUUID uuid1(v.asUUID()); // SAD LLUUID uuid2 = v; ensure_equals("contruct LLUUID", uuid1, LLUUID(uuidStr)); ensure_equals("initialize LLUUID", uuid2, LLUUID(uuidStr)); std::string dateStr = "2005-10-24T15:00:00Z"; v = dateStr; LLDate date1(v.asDate()); // SAD LLDate date2 = v; ensure_equals("contruct LLDate", date1.asString(), dateStr); ensure_equals("initialize LLDate", date2.asString(), dateStr); std::string uriStr = "http://secondlife.com"; v = uriStr; LLURI uri1(v.asURI()); // SAD LLURI uri2 = v; ensure_equals("contruct LLURI", uri1.asString(), uriStr); ensure_equals("initialize LLURI", uri2.asString(), uriStr); }
void lllogininstance_object::test<2>() { set_test_name("Test User TOS/Critical message Interaction"); const std::string test_uri = "testing-uri"; // Test default connect. logininstance->connect(test_uri, agentCredential); // connect should call LLLogin::connect to init gLoginURI and gLoginCreds. ensure_equals("Default connect uri", gLoginURI, "testing-uri"); ensure_equals("Default for agree to tos", gLoginCreds["params"]["agree_to_tos"].asBoolean(), false); ensure_equals("Default for read critical", gLoginCreds["params"]["read_critical"].asBoolean(), false); // TOS failure response. LLSD response; response["state"] = "offline"; response["change"] = "fail.login"; response["progress"] = 0.0; response["transfer_rate"] = 7; response["data"]["reason"] = "tos"; gTestPump.post(response); ensure_equals("TOS Dialog type", gTOSType, "message_tos"); ensure("TOS callback given", gTOSReplyPump != 0); gTOSReplyPump->post(false); // Call callback denying TOS. ensure("No TOS, failed auth", logininstance->authFailure()); // Start again. logininstance->connect(test_uri, agentCredential); gTestPump.post(response); // Fail for tos again. gTOSReplyPump->post(true); // Accept tos, should reconnect w/ agree_to_tos. ensure_equals("Accepted agree to tos", gLoginCreds["params"]["agree_to_tos"].asBoolean(), true); ensure("Incomplete login status", !logininstance->authFailure() && !logininstance->authSuccess()); // Fail connection, attempt connect again. // The new request should have reset agree to tos to default. response["data"]["reason"] = "key"; // bad creds. gTestPump.post(response); ensure("TOS auth failure", logininstance->authFailure()); logininstance->connect(test_uri, agentCredential); ensure_equals("Reset to default for agree to tos", gLoginCreds["params"]["agree_to_tos"].asBoolean(), false); // Critical Message failure response. logininstance->connect(test_uri, agentCredential); response["data"]["reason"] = "critical"; // Change response to "critical message" gTestPump.post(response); ensure_equals("TOS Dialog type", gTOSType, "message_critical"); ensure("TOS callback given", gTOSReplyPump != 0); gTOSReplyPump->post(true); ensure_equals("Accepted read critical message", gLoginCreds["params"]["read_critical"].asBoolean(), true); ensure("Incomplete login status", !logininstance->authFailure() && !logininstance->authSuccess()); // Fail then attempt new connection response["data"]["reason"] = "key"; // bad creds. gTestPump.post(response); ensure("TOS auth failure", logininstance->authFailure()); logininstance->connect(test_uri, agentCredential); ensure_equals("Default for agree to tos", gLoginCreds["params"]["read_critical"].asBoolean(), false); }
void SDTestObject::test<11>() // array operations { SDCleanupCheck check; LLSD v; ensure_equals("undefined has no size", v.size(), 0); ensure("undefined get() is undefined", v.get(0).isUndefined()); v = LLSD::emptyArray(); ensure("empty array is an array", v.isArray()); ensure_equals("empty array has no size", v.size(), 0); ensure("empty map get() is undefined", v.get(0).isUndefined()); v.clear(); v.append(88); v.append("noodle"); v.append(true); ensure_equals("appened array size", v.size(), 3); ensure("append array is an array", v.isArray()); ensureTypeAndValue("append 0", v[0], 88); ensureTypeAndValue("append 1", v[1], "noodle"); ensureTypeAndValue("append 2", v[2], true); v.insert(0, 77); v.insert(2, "soba"); v.insert(4, false); ensure_equals("inserted array size", v.size(), 6); ensureTypeAndValue("post insert 0", v[0], 77); ensureTypeAndValue("post insert 1", v[1], 88); ensureTypeAndValue("post insert 2", v[2], "soba"); ensureTypeAndValue("post insert 3", v[3], "noodle"); ensureTypeAndValue("post insert 4", v[4], false); ensureTypeAndValue("post insert 5", v[5], true); ensureTypeAndValue("get 1", v.get(1), 88); v.set(1, "hot"); ensureTypeAndValue("set 1", v.get(1), "hot"); v.erase(3); ensure_equals("post erase array size", v.size(), 5); ensureTypeAndValue("post erase 0", v[0], 77); ensureTypeAndValue("post erase 1", v[1], "hot"); ensureTypeAndValue("post erase 2", v[2], "soba"); ensureTypeAndValue("post erase 3", v[3], false); ensureTypeAndValue("post erase 4", v[4], true); v.append(34); ensure_equals("size after append", v.size(), 6); ensureTypeAndValue("post append 5", v[5], 34); LLSD w; w = v; ensure("copy array type", w.isArray()); ensure_equals("copy array size", w.size(), 6); ensureTypeAndValue("copy array 0", w[0], 77); ensureTypeAndValue("copy array 1", w[1], "hot"); ensureTypeAndValue("copy array 2", w[2], "soba"); ensureTypeAndValue("copy array 3", w[3], false); ensureTypeAndValue("copy array 4", w[4], true); ensureTypeAndValue("copy array 5", w[5], 34); }
void testObj::test<1>(void) { ensure_equals("invalid type set", impl_.getType().str(), "sometype"); }
void testObj::test<1>(void) { env_.run("tmp=persistency.OptionalString(\"test string\")"); ensure_equals("invalid value", env_.var<OptionalString>("tmp").get(), string("test string")); }
void testObj::test<2>(void) { ensure_equals("invalid name set", impl_.getName().str(), "somename"); }
void testObj::test<2>(void) { ensure_equals("invalid WRITE value", Mode::WRITE, 2); }
void checkExpected(Geometry* result, const Geometry* expected) { bool isEqual = result->equalsExact(expected, 1.0e-5); ensure_equals("Expect: "+writer.write(expected)+" Obtained: "+writer.write(result), isEqual, true); }