TEST_F(HookRegistrationTest, contextIsAccessibleInAfterHooks) { beginScenario(0); endScenario(); EXPECT_EQ(CONTEXT_MARKER, contextContents); }
TEST_F(TestFileFactory, Write) { XFILE::CFile file, inputfile; std::string str; unsigned int size, i; unsigned char buf[16]; int64_t count = 0; str = CXBMCTestUtils::Instance().getTestFileFactoryWriteInputFile(); ASSERT_TRUE(inputfile.Open(str)); std::vector<std::string> urls = CXBMCTestUtils::Instance().getTestFileFactoryWriteUrls(); std::vector<std::string>::iterator it; for (it = urls.begin(); it < urls.end(); ++it) { std::cout << "Testing URL: " << *it << std::endl; std::cout << "Writing..."; ASSERT_TRUE(file.OpenForWrite(*it, true)); while ((size = inputfile.Read(buf, sizeof(buf))) > 0) { EXPECT_GE(file.Write(buf, size), 0); } file.Close(); std::cout << "done." << std::endl; std::cout << "Reading..." << std::endl; ASSERT_TRUE(file.Open(*it)); EXPECT_EQ(inputfile.GetLength(), file.GetLength()); std::cout << "file.Seek(file.GetLength() / 2, SEEK_CUR) return value: " << testing::PrintToString(file.Seek(file.GetLength() / 2, SEEK_CUR)) << std::endl; std::cout << "file.Seek(0, SEEK_END) return value: " << testing::PrintToString(file.Seek(0, SEEK_END)) << std::endl; std::cout << "file.Seek(0, SEEK_SET) return value: " << testing::PrintToString(file.Seek(0, SEEK_SET)) << std::endl; std::cout << "File contents:\n"; while ((size = file.Read(buf, sizeof(buf))) > 0) { str = StringUtils::Format(" %08lX", count); std::cout << str << " "; count += size; for (i = 0; i < size; i++) { str = StringUtils::Format("%02X ", buf[i]); std::cout << str; } while (i++ < sizeof(buf)) std::cout << " "; std::cout << " ["; for (i = 0; i < size; i++) { if (buf[i] >= ' ' && buf[i] <= '~') std::cout << buf[i]; else std::cout << "."; } std::cout << "]" << std::endl; } file.Close(); } inputfile.Close(); }
TEST(Utils, Config) { Config c("data/s3test.conf"); EXPECT_EQ(c.Get("configtest", "config1", "aaaaaa"), "abcdefg"); EXPECT_EQ(c.Get("configtest", "config2", "tttt"), "12345"); EXPECT_EQ(c.Get("configtest", "config3", "tttt"), "aaaaa"); EXPECT_EQ(c.Get("configtest", "config4", "tttt"), "123"); EXPECT_EQ(c.Get("configtest", "config5", "tttt"), "tttt"); EXPECT_EQ(c.Get("configtest", "config6", "tttt"), "tttt"); EXPECT_EQ(c.Get("configtest", "config7", "xx"), "xx"); EXPECT_EQ(c.Get("configtest", "", "xx"), "xx"); EXPECT_EQ(c.Get("configtest", "config7", ""), ""); EXPECT_EQ(c.Get("configtest", "", "xx"), "xx"); uint64_t value = 0; EXPECT_TRUE(c.Scan("configtest", "config2", "%" PRIu64, &value)); EXPECT_EQ((uint64_t)12345, value); EXPECT_TRUE(c.Scan("configtest", "config4", "%" PRIu64, &value)); EXPECT_EQ((uint64_t)123, value); EXPECT_FALSE(c.Scan("configtest", "config7", "%" PRIu64, &value)); EXPECT_FALSE(c.Scan("", "config7", "%" PRIu64, &value)); EXPECT_FALSE(c.Scan("configtest", "", "%" PRIu64, &value)); EXPECT_FALSE(c.Scan("configtest", "config5", "%" PRIu64, &value)); char str[128]; EXPECT_TRUE(c.Scan("configtest", "config3", "%s", str)); EXPECT_STREQ(str, "aaaaa"); }
TEST(Type, ToString) { EXPECT_EQ("Int", Type::Int.toString()); EXPECT_EQ("Cell", Type::Cell.toString()); EXPECT_EQ("BoxedDbl", Type::BoxedDbl.toString()); }
TEST( regular_vector, usage ) { comma::regular_vector< double, int > v( 1.2, 0.5, 10 ); v( 2.1 ) = 5; EXPECT_EQ( 5, v[ v.index( 2.1 ) ] ); }
void elementAtIndexMustBe(int index, T expected) { EXPECT_EQ(expected, (*_array)[index].as<T>()); }
TEST_F(SubMakefileCreatorTest, setOutputter) { IOutputter* outputter = new OutputterMock(); sut->setOutputter( outputter ); EXPECT_EQ(outputter, sut->getOutputter()); }
TEST(CircleTests, CircumferenceTest) { Circle myCircle(3); EXPECT_EQ(6*M_PI,myCircle.getCircumference()); }
TEST(CircleTests, RadiusTest) { Circle myCircle(3); EXPECT_EQ(3,myCircle.getRadius()); myCircle.setRadius(4); EXPECT_EQ(4, myCircle.getRadius()); }
static inline void check_item (undo_handler &handler, int index, int value) { undoable_stub *item = dynamic_cast<undoable_stub *>(handler.get_item (index)); EXPECT_NE (nullptr, item); EXPECT_EQ (value, item->m_data); }
TEST(CircleTests, AreaTest) { Circle myCircle(3); EXPECT_EQ(9*M_PI,myCircle.getArea()); }
TEST_F(DBHandleTests, test_delete) { db->Put(kQueries, "test_delete", "baz"); auto s = db->Delete(kQueries, "test_delete"); EXPECT_TRUE(s.ok()); EXPECT_EQ(s.toString(), "OK"); }
TEST_F(DBHandleTests, test_put) { auto s = db->Put(kQueries, "test_put", "bar"); EXPECT_TRUE(s.ok()); EXPECT_EQ(s.toString(), "OK"); }
TEST_F(DBHandleTests, test_singleton_on_disk) { auto db1 = DBHandle::getInstance(); auto db2 = DBHandle::getInstance(); EXPECT_EQ(db1, db2); }
TEST_F(DepotTest, fire) { Depot depot(loc, entr, size, name, health); EXPECT_FALSE(depot.isBurning()); EXPECT_DEATH(depot.burningDown(), ""); // ooops, depot is not on fire EXPECT_DEATH(depot.stopFire(), ""); // oops, depot is not on fire EXPECT_FALSE(depot.isDead()); EXPECT_FALSE(depot.startSpreadingFire()); EXPECT_FALSE(depot.startRepair()); EXPECT_DEATH(depot.repair(), ""); // oops, Depot has still it's original health EXPECT_FALSE(depot.isFireTruckAssigned()); EXPECT_DEATH(depot.assignFireTruck(), ""); // oops, the Depot is not on fire EXPECT_DEATH(depot.withdrawFireTruckAssignment(), ""); // oops, there is no firetruck assigned // okay, start the fire scenario EXPECT_NO_FATAL_FAILURE(depot.setFire()); EXPECT_TRUE(depot.isBurning()); EXPECT_NO_FATAL_FAILURE(depot.burningDown()); EXPECT_EQ(health - reducer, depot.getHealth()); EXPECT_FALSE(depot.isDead()); EXPECT_FALSE(depot.startSpreadingFire()); // No, it has lost "only" 2 health points EXPECT_FALSE(depot.startRepair()); EXPECT_DEATH(depot.repair(), ""); // oops, Depot is still on fire // let's send a firetruck EXPECT_NO_FATAL_FAILURE(depot.assignFireTruck()); EXPECT_TRUE(depot.isFireTruckAssigned()); // extinguish fire, repair and sendback firetruck EXPECT_DEATH(depot.withdrawFireTruckAssignment(), ""); // oops, Depot is still on fire EXPECT_NO_FATAL_FAILURE(depot.stopFire()); EXPECT_FALSE(depot.isBurning()); EXPECT_TRUE(depot.startRepair()); EXPECT_NO_FATAL_FAILURE(depot.repair()); EXPECT_EQ(health - reducer + 0.5, depot.getHealth()); EXPECT_NO_FATAL_FAILURE(depot.withdrawFireTruckAssignment()); EXPECT_FALSE(depot.isFireTruckAssigned()); EXPECT_FALSE(depot.isDead()); // fire breaks out again EXPECT_NO_FATAL_FAILURE(depot.setFire()); EXPECT_TRUE(depot.isBurning()); EXPECT_NO_FATAL_FAILURE(depot.burningDown()); EXPECT_EQ(health - reducer + 0.5 - reducer, depot.getHealth()); EXPECT_FALSE(depot.isDead()); EXPECT_TRUE(depot.startSpreadingFire()); // let them burning down 'till death EXPECT_NO_FATAL_FAILURE(depot.burningDown()); EXPECT_TRUE(depot.isDead()); EXPECT_EQ(health - reducer + 0.5 - reducer - reducer, depot.getHealth()); // now, Depot is not on fire anymore EXPECT_FALSE(depot.isBurning()); EXPECT_FALSE(depot.startRepair()); // you cannot repair a dead Depot EXPECT_FALSE(depot.startSpreadingFire()); }
TEST(NullIterator, HasZeroValues) { auto it = Iterators::browseNothing<int>(); EXPECT_EQ(countValues(it), 0); }
void parseMustFail() { _array = &_jsonBuffer.parseArray(_jsonString); EXPECT_FALSE(_array->success()); EXPECT_EQ(0, _array->size()); }
TEST_F(TestArrayHandler, generateArray) { EXPECT_EQ(expected, actual) << "Expected and actual values are not the same"; }
TEST(bodyPartTest, GetAndSetTest) { BodyPart bp1; int partID = 3; string partName = "Part Name"; int parentJoint = 0; int childJoint = 0; bool isOccluded = false; float expectedDistance = 1.343f; POSERECT <Point2f> polygon(Point2f(1.0f, 2.0f), Point2f(2.0f, 3.0f), Point2f(3.0f, 4.0f), Point2f(4.0f, 5.0f)); float lwRatio = 1.3f; float relativeLength = 0.6f; float searchRadius = 0.5f; float rotationSearchRange = 3.14f; bp1.setPartID(partID); bp1.setPartName(partName); bp1.setParentJoint(parentJoint); bp1.setChildJoint(childJoint); bp1.setIsOccluded(isOccluded); bp1.setExpectedDistance(expectedDistance); bp1.setPartPolygon(polygon); bp1.setLWRatio(lwRatio); bp1.setRelativeLength(relativeLength); bp1.setSearchRadius(searchRadius); bp1.setRotationSearchRange(rotationSearchRange); EXPECT_EQ(partID, bp1.getPartID()); EXPECT_EQ(partName, bp1.getPartName()); EXPECT_EQ(parentJoint, bp1.getParentJoint()); EXPECT_EQ(childJoint, bp1.getChildJoint()); EXPECT_EQ(isOccluded, bp1.getIsOccluded()); EXPECT_EQ(expectedDistance, bp1.getExpectedDistance()); EXPECT_EQ(polygon, bp1.getPartPolygon()); EXPECT_EQ(lwRatio, bp1.getLWRatio()); EXPECT_EQ(relativeLength, bp1.getRelativeLength()); EXPECT_EQ(searchRadius, bp1.getSearchRadius()); EXPECT_EQ(rotationSearchRange, bp1.getRotationSearchRange()); }
TEST_F(QueueTest, Basic) { buildSimpleTree(); dump(); EXPECT_EQ(nodes_, IDList({{1, 100}, {3, 25}, {5, 25}, {9, 100}, {7, 50}})); }
TEST(Type, UnionOf) { EXPECT_EQ(Type::PtrToGen, Type::unionOf(Type::PtrToCell, Type::PtrToGen)); EXPECT_EQ(Type::UncountedInit, Type::unionOf(Type::Int, Type::Dbl)); EXPECT_EQ(Type::Str, Type::unionOf(Type::StaticStr, Type::Str)); EXPECT_EQ(Type::Gen, Type::unionOf(Type::Cell, Type::BoxedInt)); }
TEST_F(QueueTest, AddMax) { addTransaction(1, {0, false, 255}); nextEgress(); EXPECT_EQ(nodes_, IDList({{1, 100}})); }
TEST(Type, FromString) { EXPECT_EQ(Type::Int, Type::fromString("Int")); EXPECT_EQ(Type::None, Type::fromString("Blah")); EXPECT_EQ(Type::PtrToBoxedInt, Type::fromString("PtrToBoxedInt")); }
TEST(TupleTest, Basic) { Tuple1<int> t1(1); Tuple2<int, const char*> t2 = MakeTuple(1, static_cast<const char*>("wee")); Tuple3<int, int, int> t3(1, 2, 3); Tuple4<int, int, int, int*> t4(1, 2, 3, &t1.a); Tuple5<int, int, int, int, int*> t5(1, 2, 3, 4, &t4.a); Tuple6<int, int, int, int, int, int*> t6(1, 2, 3, 4, 5, &t4.a); EXPECT_EQ(1, t1.a); EXPECT_EQ(1, t2.a); EXPECT_EQ(1, t3.a); EXPECT_EQ(2, t3.b); EXPECT_EQ(3, t3.c); EXPECT_EQ(1, t4.a); EXPECT_EQ(2, t4.b); EXPECT_EQ(3, t4.c); EXPECT_EQ(1, t5.a); EXPECT_EQ(2, t5.b); EXPECT_EQ(3, t5.c); EXPECT_EQ(4, t5.d); EXPECT_EQ(1, t6.a); EXPECT_EQ(2, t6.b); EXPECT_EQ(3, t6.c); EXPECT_EQ(4, t6.d); EXPECT_EQ(5, t6.e); EXPECT_EQ(1, t1.a); DispatchToFunction(&DoAdd, t4); EXPECT_EQ(6, t1.a); int res = 0; DispatchToFunction(&DoAdd, MakeTuple(9, 8, 7, &res)); EXPECT_EQ(24, res); Addy addy; EXPECT_EQ(1, t4.a); DispatchToMethod(&addy, &Addy::DoAdd, t5); EXPECT_EQ(10, t4.a); Addz addz; EXPECT_EQ(10, t4.a); DispatchToMethod(&addz, &Addz::DoAdd, t6); EXPECT_EQ(15, t4.a); }
TEST( regular_vector, index ) { { comma::regular_vector< double, int > v( 1.2, 0.5, 10 ); EXPECT_EQ( -1, v.index( 1 ) ); EXPECT_EQ( 0, v.index( 1.2 ) ); EXPECT_EQ( 0, v.index( 1.3 ) ); EXPECT_EQ( 0, v.index( 1.4999 ) ); EXPECT_EQ( 2, v.index( 2.2 ) ); EXPECT_EQ( 2, v.index( 2.3 ) ); EXPECT_EQ( 2, v.index( 2.4999 ) ); } { comma::regular_vector< double, int > v( -1.0, 0.5, 10 ); EXPECT_EQ( -2, v.index( -1.5000001 ) ); EXPECT_EQ( -1, v.index( -1.5 ) ); EXPECT_EQ( -1, v.index( -1.4999999 ) ); EXPECT_EQ( -1, v.index( -1.0000001 ) ); EXPECT_EQ( 0, v.index( -1 ) ); EXPECT_EQ( 0, v.index( -0.9999999 ) ); EXPECT_EQ( 1, v.index( -0.0000001 ) ); EXPECT_EQ( 2, v.index( 0 ) ); EXPECT_EQ( 2, v.index( 0.0000001 ) ); } }
TEST(transform_constant, constant) { constexpr int ic = 12345; typedef constant<std::decay<decltype(ic)>::type, ic> i; EXPECT_EQ(ic, (i::type<>::value)); EXPECT_EQ(ic, (i::type<bool>::value)); EXPECT_EQ(ic, (i::type<int>::value)); EXPECT_EQ(ic, (i::type<std::string>::value)); EXPECT_EQ(ic, (i::type<double>::value)); EXPECT_EQ(ic, (i::type<double, void>::value)); EXPECT_EQ(ic, (i::type<transform::identity<double>>::value)); constexpr bool bc = true; typedef constant<std::decay<decltype(bc)>::type, bc> b; EXPECT_EQ(bc, (b::type<>::value)); EXPECT_EQ(bc, (b::type<bool>::value)); EXPECT_EQ(bc, (b::type<int>::value)); EXPECT_EQ(bc, (b::type<std::string>::value)); EXPECT_EQ(bc, (b::type<double>::value)); EXPECT_EQ(bc, (b::type<double, void>::value)); EXPECT_EQ(bc, (b::type<transform::identity<double>>::value)); }
TEST(Common, UrlOptions) { EXPECT_EQ("secret_test", GetOptS3(string("s3://neverland.amazonaws.com secret=secret_test"), "secret")); EXPECT_EQ("\".\\!@#$%^&*()DFGHJK\"", GetOptS3(string("s3://neverland.amazonaws.com accessid=\".\\!@#$%^&*()DFGHJK\""), "accessid")); EXPECT_EQ("3456789", GetOptS3(string("s3://neverland.amazonaws.com chunksize=3456789"), "chunksize")); EXPECT_EQ("secret_test", GetOptS3(string("s3://neverland.amazonaws.com secret=secret_test " "accessid=\".\\!@#$%^&*()DFGHJK\" chunksize=3456789"), "secret")); EXPECT_EQ("\".\\!@#$%^&*()DFGHJK\"", GetOptS3(string("s3://neverland.amazonaws.com secret=secret_test " "accessid=\".\\!@#$%^&*()DFGHJK\" chunksize=3456789"), "accessid")); EXPECT_EQ("3456789", GetOptS3(string("s3://neverland.amazonaws.com secret=secret_test " "accessid=\".\\!@#$%^&*()DFGHJK\" chunksize=3456789"), "chunksize")); EXPECT_EQ("secret_test", GetOptS3(string("s3://neverland.amazonaws.com secret=secret_test " "blah=whatever accessid=\".\\!@#$%^&*()DFGHJK\" " "chunksize=3456789 testKey=testValue"), "secret")); EXPECT_EQ("secret_test", GetOptS3(string("s3://neverland.amazonaws.com secret=secret_test " "blah= accessid=\".\\!@#$%^&*()DFGHJK\" " "chunksize=3456789 testKey=testValue"), "secret")); EXPECT_EQ("3456789", GetOptS3(string("s3://neverland.amazonaws.com secret=secret_test " "chunksize=3456789 testKey=testValue "), "chunksize")); EXPECT_EQ("3456789", GetOptS3(string("s3://neverland.amazonaws.com secret=secret_test " "chunksize=3456789 testKey=testValue "), "chunksize")); EXPECT_EQ("=testValue", GetOptS3(string("s3://neverland.amazonaws.com secret=secret_test " "chunksize=3456789 testKey==testValue "), "testKey")); EXPECT_EQ("secret=secret", GetOptS3(string("s3://neverland.amazonaws.com secret=secret=secret " "chunksize=3456789 testKey==testValue "), "secret")); EXPECT_TRUE(GetOptS3(string(""), "accessid").empty()); EXPECT_TRUE(GetOptS3(string("s3://neverland.amazonaws.com secret=secret_test " "accessid=\".\\!@#$%^&*()DFGHJK\" chunksize=3456789"), "secret1") .empty()); EXPECT_TRUE(GetOptS3(string("s3://neverland.amazonaws.com"), "secret").empty()); EXPECT_TRUE(GetOptS3(string("s3://neverland.amazonaws.com secret=secret_test blah=whatever " "accessid= chunksize=3456789 testKey=testValue"), "accessid") .empty()); EXPECT_TRUE(GetOptS3(string("s3://neverland.amazonaws.com secret=secret_test blah=whatever " "chunksize=3456789 testKey=testValue"), "") .empty()); EXPECT_TRUE(GetOptS3(string("s3://neverland.amazonaws.com secret=secret_test " "chunksize=3456789 testKey=testValue "), "chunk size") .empty()); }
TEST_F(DepotTest, vehicles) { Depot depot(loc, entr, size, name, health); EXPECT_NO_FATAL_FAILURE(depot.addVehicle(ptrCar0)); EXPECT_EQ(1, depot.getAvailableVehicles()); EXPECT_EQ(1, depot.getNrVehicles()); EXPECT_NO_FATAL_FAILURE(depot.addVehicle(ptrCar1)); EXPECT_EQ(2, depot.getAvailableVehicles()); EXPECT_EQ(2, depot.getNrVehicles()); EXPECT_NO_FATAL_FAILURE(ptrCar0->goUp()); EXPECT_EQ(1, depot.getAvailableVehicles()); EXPECT_EQ(2, depot.getNrVehicles()); EXPECT_NO_FATAL_FAILURE(ptrCar1->goUp()); EXPECT_EQ(0, depot.getAvailableVehicles()); EXPECT_EQ(2, depot.getNrVehicles()); EXPECT_NO_FATAL_FAILURE(ptrCar0->goDown()); EXPECT_EQ(1, depot.getAvailableVehicles()); EXPECT_EQ(2, depot.getNrVehicles()); EXPECT_NO_FATAL_FAILURE(ptrCar1->goDown()); EXPECT_EQ(2, depot.getAvailableVehicles()); EXPECT_EQ(2, depot.getNrVehicles()); }
TEST_F(WseRtpApPacketTest, TestH264Aggregation) { UINT32 count = 0; UINT8 *outputBuffer = new UINT8[1024]; UINT32 length = 1024; wrtp::FragmentBuffer *nals = m_pFragments; EXPECT_EQ(-1, m_pH264Packer->Aggregate(nals, count, outputBuffer, length)); delete outputBuffer; outputBuffer = NULL; EXPECT_EQ(-1, m_pH264Packer->Aggregate(nals, count, outputBuffer, length)); length = 0; EXPECT_EQ(-1, m_pH264Packer->Aggregate(nals, count, outputBuffer, length)); // create several NALs shark::CWseH264AggregationAOperator::H264NUHeader *pNuHeader = NULL; count = 0; int expectedStapLen = 0; for (int k=0; k < FRAGMENT_NUM; k++) { pNuHeader = (shark::CWseH264AggregationAOperator::H264NUHeader *)(m_pFragments[k].pBuffer); m_pFragments[k].fragmentLength = s_H264NALs[k].len; pNuHeader->m_fzb = s_H264NALs[k].fzb; pNuHeader->m_nri = s_H264NALs[k].nri; pNuHeader->m_type = s_H264NALs[k].type; expectedStapLen += (2 + s_H264NALs[k].len); count++; } nals = m_pFragments; outputBuffer = new UINT8[1200]; length = 1000; EXPECT_EQ(-1, m_pH264Packer->Aggregate(nals, count, outputBuffer, length)); length = 1200; EXPECT_EQ(0, m_pH264Packer->Aggregate(nals, count, outputBuffer, length)); EXPECT_EQ(expectedStapLen+1, length); UINT8* rawData = outputBuffer; UINT32 rawLength = expectedStapLen+1; UINT32 rawCount = count; wrtp::FragmentBuffer *rawNals = NULL; EXPECT_EQ(rawCount, m_pH264Packer->GetContainedNALCount(rawData, rawLength)); EXPECT_EQ(0, m_pH264Packer->GetContainedNALCount(rawData, rawLength-1)); EXPECT_EQ(0, m_pH264Packer->GetContainedNALCount(rawData, rawLength+1)); //FIXME EXPECT_EQ(0, m_pH264Packer->GetContainedNALCount(rawData, 0)); EXPECT_EQ(0, m_pH264Packer->GetContainedNALCount(NULL, rawLength)); rawNals = new wrtp::FragmentBuffer[rawCount]; for (int k=0; k<rawCount; k++) { rawNals[k].pBuffer = new unsigned char[MAX_STAP_SIZE]; rawNals[k].fragmentLength = 0; rawNals[k].bufferLength = MAX_STAP_SIZE; } EXPECT_EQ(0, m_pH264Packer->Deaggregate(rawData, rawLength, rawNals, rawCount)); for (int k=0; k<rawCount; k++) { EXPECT_EQ(rawNals[k].fragmentLength, m_pFragments[k].fragmentLength); if (rawNals[k].fragmentLength == m_pFragments[k].fragmentLength) { int ret = memcmp(rawNals[k].pBuffer, m_pFragments[k].pBuffer, m_pFragments[k].fragmentLength); EXPECT_EQ(0, ret); } } }
TEST(libclang, clang_createTranslationUnit_InvalidArgs) { EXPECT_EQ(nullptr, clang_createTranslationUnit(nullptr, nullptr)); }