Ejemplo n.º 1
0
TEST(FunctionBigNumber, OddBigWholeNumber)
{
  MyOddWeb::BigNumber x("1234567890987654321123456781");
  ASSERT_TRUE(x.IsOdd());
  ASSERT_FALSE(x.IsEven());
}
Ejemplo n.º 2
0
TEST_F(BooleanEnumTest, test1)
{
    BooleanTest f1 = BooleanTest::F;
    BooleanTest t1 = BooleanTest::T;
    BooleanTest tmp = BooleanTest::T;

    {
        std::stringstream ss;

        ss << f1;
        ASSERT_TRUE(ss.good());
        ASSERT_FALSE(ss.fail());
        ASSERT_FALSE(ss.bad());

        ASSERT_EQ(ss.str(),std::string("BooleanTest::F"));

        ss >> tmp;

        ASSERT_TRUE(ss.good());
        ASSERT_FALSE(ss.fail());
        ASSERT_FALSE(ss.bad());

        ASSERT_EQ(tmp, BooleanTest::F);
        ss >> tmp;
        ASSERT_TRUE(ss.fail());
        ASSERT_TRUE(ss.eof());
        ASSERT_TRUE(ss.bad());
        ASSERT_FALSE(ss.good());
        ASSERT_FALSE(ss);
    }

    {
        std::stringstream ss;

        ASSERT_TRUE(ss.good());
        ASSERT_FALSE(ss.fail());
        ASSERT_FALSE(ss.bad());

        ss << t1;
        ASSERT_TRUE(ss.good());
        ASSERT_FALSE(ss.fail());
        ASSERT_FALSE(ss.bad());

        ASSERT_EQ(ss.str(),std::string("BooleanTest::T"));
        ss >> tmp;
        ASSERT_TRUE(ss.good());
        ASSERT_FALSE(ss.fail());
        ASSERT_FALSE(ss.bad());

        ASSERT_EQ(tmp, BooleanTest::T);
        ss >> tmp;
        ASSERT_TRUE(ss.fail());
        ASSERT_TRUE(ss.eof());
        ASSERT_TRUE(ss.bad());
        ASSERT_FALSE(ss.good());
        ASSERT_FALSE(ss);
    }
}
TEST(NumLib, TimeSteppingIterationNumberBased1)
{
    std::vector<std::size_t> iter_times_vector = {0, 3, 5, 7};
    std::vector<double> multiplier_vector = {2.0, 1.0, 0.5, 0.25};
    NumLib::IterationNumberBasedAdaptiveTimeStepping alg(1, 31, 1, 10, 1, iter_times_vector, multiplier_vector);

    ASSERT_TRUE(alg.next()); // t=2, dt=1
    NumLib::TimeStep ts = alg.getTimeStep();
    ASSERT_EQ(1u, ts.steps());
    ASSERT_EQ(1., ts.previous());
    ASSERT_EQ(2., ts.current());
    ASSERT_EQ(1., ts.dt());
    ASSERT_TRUE(alg.accepted());

    ASSERT_TRUE(alg.next()); // t=4, dt=2

    // dt*=2
    alg.setNIterations(3);
    ASSERT_TRUE(alg.next()); // t=8, dt=4
    ts = alg.getTimeStep();
    ASSERT_EQ(3u, ts.steps());
    ASSERT_EQ(4., ts.previous());
    ASSERT_EQ(8., ts.current());
    ASSERT_EQ(4., ts.dt());
    ASSERT_TRUE(alg.accepted());

    // dt*=1
    alg.setNIterations(5);
    ASSERT_TRUE(alg.next()); // t=12, dt=4
    ts = alg.getTimeStep();
    ASSERT_EQ(4u, ts.steps());
    ASSERT_EQ(8., ts.previous());
    ASSERT_EQ(12., ts.current());
    ASSERT_EQ(4., ts.dt());
    ASSERT_TRUE(alg.accepted());

    // dt*=0.5
    alg.setNIterations(7);
    ASSERT_TRUE(alg.next()); // t=14, dt=2
    ts = alg.getTimeStep();
    ASSERT_EQ(5u, ts.steps());
    ASSERT_EQ(12., ts.previous());
    ASSERT_EQ(14., ts.current());
    ASSERT_EQ(2., ts.dt());
    ASSERT_TRUE(alg.accepted());

    // dt*=0.25 but dt_min = 1
    alg.setNIterations(8); // exceed max
    ASSERT_TRUE(alg.next()); // t=13, dt=1
    ts = alg.getTimeStep();
    ASSERT_EQ(5u, ts.steps());
    ASSERT_EQ(12., ts.previous());
    ASSERT_EQ(13, ts.current());
    ASSERT_EQ(1., ts.dt());
    ASSERT_FALSE(alg.accepted());

    // restart, dt*=1
    alg.setNIterations(4);
    ASSERT_TRUE(alg.next()); // t=14, dt=1
    ts = alg.getTimeStep();
    ASSERT_EQ(6u, ts.steps());
    ASSERT_EQ(13., ts.previous());
    ASSERT_EQ(14, ts.current());
    ASSERT_EQ(1., ts.dt());
    ASSERT_TRUE(alg.accepted());
}
Ejemplo n.º 4
0
TEST(TestMemFile, BadReadFromCache) {
  StaticContentCache::TheFileCache = FileCachePtr(new FileCache());

  MemFile mf;
  ASSERT_FALSE(mf.open("/some/random/file", "r"));
}
Ejemplo n.º 5
0
TEST(TestMemFile, NotInCache) {
  StaticContentCache::TheFileCache = FileCachePtr(new FileCache());

  MemFile mf;
  ASSERT_FALSE(mf.open("/not/even/there", "r"));
}
Ejemplo n.º 6
0
TEST(TEST_CASE_LABEL, are_reference) {
    ASSERT_EQ((are_reference<A&&>::value), (are_reference_v<A&&>));
    ASSERT_TRUE((are_reference_v<B&>));
    ASSERT_FALSE((are_reference_v<A&, B, D&&>));
    ASSERT_TRUE((are_reference_v<A&, B&&, D&>));
}
TEST_F(ScrollingCoordinatorTest, fastScrollingForFixedPosition)
{
    registerMockedHttpURLLoad("fixed-position.html");
    navigateTo(m_baseURL + "fixed-position.html");
    forceFullCompositingUpdate();

    // Fixed position should not fall back to main thread scrolling.
    WebLayer* rootScrollLayer = getRootScrollLayer();
    ASSERT_FALSE(rootScrollLayer->shouldScrollOnMainThread());

    Document* document = frame()->document();
    {
        Element* element = document->getElementById("div-tl");
        ASSERT_TRUE(element);
        WebLayer* layer = webLayerFromElement(element);
        ASSERT_TRUE(layer);
        WebLayerPositionConstraint constraint = layer->positionConstraint();
        ASSERT_TRUE(constraint.isFixedPosition);
        ASSERT_TRUE(!constraint.isFixedToRightEdge && !constraint.isFixedToBottomEdge);
    }
    {
        Element* element = document->getElementById("div-tr");
        ASSERT_TRUE(element);
        WebLayer* layer = webLayerFromElement(element);
        ASSERT_TRUE(layer);
        WebLayerPositionConstraint constraint = layer->positionConstraint();
        ASSERT_TRUE(constraint.isFixedPosition);
        ASSERT_TRUE(constraint.isFixedToRightEdge && !constraint.isFixedToBottomEdge);
    }
    {
        Element* element = document->getElementById("div-bl");
        ASSERT_TRUE(element);
        WebLayer* layer = webLayerFromElement(element);
        ASSERT_TRUE(layer);
        WebLayerPositionConstraint constraint = layer->positionConstraint();
        ASSERT_TRUE(constraint.isFixedPosition);
        ASSERT_TRUE(!constraint.isFixedToRightEdge && constraint.isFixedToBottomEdge);
    }
    {
        Element* element = document->getElementById("div-br");
        ASSERT_TRUE(element);
        WebLayer* layer = webLayerFromElement(element);
        ASSERT_TRUE(layer);
        WebLayerPositionConstraint constraint = layer->positionConstraint();
        ASSERT_TRUE(constraint.isFixedPosition);
        ASSERT_TRUE(constraint.isFixedToRightEdge && constraint.isFixedToBottomEdge);
    }
    {
        Element* element = document->getElementById("span-tl");
        ASSERT_TRUE(element);
        WebLayer* layer = webLayerFromElement(element);
        ASSERT_TRUE(layer);
        WebLayerPositionConstraint constraint = layer->positionConstraint();
        ASSERT_TRUE(constraint.isFixedPosition);
        ASSERT_TRUE(!constraint.isFixedToRightEdge && !constraint.isFixedToBottomEdge);
    }
    {
        Element* element = document->getElementById("span-tr");
        ASSERT_TRUE(element);
        WebLayer* layer = webLayerFromElement(element);
        ASSERT_TRUE(layer);
        WebLayerPositionConstraint constraint = layer->positionConstraint();
        ASSERT_TRUE(constraint.isFixedPosition);
        ASSERT_TRUE(constraint.isFixedToRightEdge && !constraint.isFixedToBottomEdge);
    }
    {
        Element* element = document->getElementById("span-bl");
        ASSERT_TRUE(element);
        WebLayer* layer = webLayerFromElement(element);
        ASSERT_TRUE(layer);
        WebLayerPositionConstraint constraint = layer->positionConstraint();
        ASSERT_TRUE(constraint.isFixedPosition);
        ASSERT_TRUE(!constraint.isFixedToRightEdge && constraint.isFixedToBottomEdge);
    }
    {
        Element* element = document->getElementById("span-br");
        ASSERT_TRUE(element);
        WebLayer* layer = webLayerFromElement(element);
        ASSERT_TRUE(layer);
        WebLayerPositionConstraint constraint = layer->positionConstraint();
        ASSERT_TRUE(constraint.isFixedPosition);
        ASSERT_TRUE(constraint.isFixedToRightEdge && constraint.isFixedToBottomEdge);
    }
}
Ejemplo n.º 8
0
TEST_F(MemoryPressureMesosTest, ROOT_CGROUPS_Statistics)
{
  Try<Owned<cluster::Master>> master = StartMaster();
  ASSERT_SOME(master);

  slave::Flags flags = CreateSlaveFlags();

  // We only care about memory cgroup for this test.
  flags.isolation = "cgroups/mem";

  Fetcher fetcher(flags);

  Try<MesosContainerizer*> _containerizer =
    MesosContainerizer::create(flags, true, &fetcher);

  ASSERT_SOME(_containerizer);
  Owned<MesosContainerizer> containerizer(_containerizer.get());

  Owned<MasterDetector> detector = master.get()->createDetector();

  Try<Owned<cluster::Slave>> slave =
    StartSlave(detector.get(), containerizer.get(), flags);
  ASSERT_SOME(slave);

  MockScheduler sched;

  MesosSchedulerDriver driver(
      &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);

  EXPECT_CALL(sched, registered(_, _, _));

  Future<vector<Offer>> offers;
  EXPECT_CALL(sched, resourceOffers(_, _))
    .WillOnce(FutureArg<1>(&offers))
    .WillRepeatedly(Return());      // Ignore subsequent offers.

  driver.start();

  AWAIT_READY(offers);
  ASSERT_FALSE(offers->empty());

  Offer offer = offers.get()[0];

  // Run a task that triggers memory pressure event. We request 1G
  // disk because we are going to write a 512 MB file repeatedly.
  TaskInfo task = createTask(
      offer.slave_id(),
      Resources::parse("cpus:1;mem:256;disk:1024").get(),
      "while true; do dd count=512 bs=1M if=/dev/zero of=./temp; done");

  Future<TaskStatus> starting;
  Future<TaskStatus> running;
  Future<TaskStatus> killed;
  EXPECT_CALL(sched, statusUpdate(&driver, _))
    .WillOnce(FutureArg<1>(&starting))
    .WillOnce(FutureArg<1>(&running))
    .WillOnce(FutureArg<1>(&killed))
    .WillRepeatedly(Return());       // Ignore subsequent updates.

  driver.launchTasks(offer.id(), {task});

  AWAIT_READY(starting);
  EXPECT_EQ(task.task_id(), starting->task_id());
  EXPECT_EQ(TASK_STARTING, starting->state());

  AWAIT_READY(running);
  EXPECT_EQ(task.task_id(), running->task_id());
  EXPECT_EQ(TASK_RUNNING, running->state());

  Future<hashset<ContainerID>> containers = containerizer->containers();
  AWAIT_READY(containers);
  ASSERT_EQ(1u, containers->size());

  ContainerID containerId = *(containers->begin());

  // Wait a while for some memory pressure events to occur.
  Duration waited = Duration::zero();
  do {
    Future<ResourceStatistics> usage = containerizer->usage(containerId);
    AWAIT_READY(usage);

    if (usage->mem_low_pressure_counter() > 0) {
      // We will check the correctness of the memory pressure counters
      // later, because the memory-hammering task is still active
      // and potentially incrementing these counters.
      break;
    }

    os::sleep(Milliseconds(100));
    waited += Milliseconds(100);
  } while (waited < Seconds(5));

  EXPECT_LE(waited, Seconds(5));

  // Pause the clock to ensure that the reaper doesn't reap the exited
  // command executor and inform the containerizer/slave.
  Clock::pause();
  Clock::settle();

  // Stop the memory-hammering task.
  driver.killTask(task.task_id());

  AWAIT_READY_FOR(killed, Seconds(120));
  EXPECT_EQ(task.task_id(), killed->task_id());
  EXPECT_EQ(TASK_KILLED, killed->state());

  // Now check the correctness of the memory pressure counters.
  Future<ResourceStatistics> usage = containerizer->usage(containerId);
  AWAIT_READY(usage);

  EXPECT_GE(usage->mem_low_pressure_counter(),
            usage->mem_medium_pressure_counter());
  EXPECT_GE(usage->mem_medium_pressure_counter(),
            usage->mem_critical_pressure_counter());

  Clock::resume();

  driver.stop();
  driver.join();
}
Ejemplo n.º 9
0
TEST_F(octtointTest, Overflow) {
	const char* str = "40000000000";
	u_long actual;

	ASSERT_FALSE(octtoint(str, &actual));
}
Ejemplo n.º 10
0
TEST(StringNumber, StringToNumber)
{
    int16_t i16;
    int32_t i32;
    int64_t i64;
    long long ll;
    unsigned long long ull;
    ASSERT_FALSE(StringToNumber("223372036854775807", &i32));
    ASSERT_TRUE(StringToNumber("223372036854775807", &i64));
    ASSERT_TRUE(StringToNumber("223372036854775807", &ll));
    ASSERT_TRUE(StringToNumber("223372036854775807", &ull));
    ASSERT_EQ(i64, 223372036854775807LL);
    ASSERT_EQ(ll, 223372036854775807LL);
    ASSERT_EQ(ull, 223372036854775807ULL);
    ASSERT_FALSE(StringToNumber("1147483647", &i16));
    ASSERT_TRUE(StringToNumber("1147483647", &i32));
    ASSERT_TRUE(StringToNumber("1147483647", &i64));
    ASSERT_EQ(i32, 1147483647);
    ASSERT_EQ(i64, 1147483647);

    uint32_t u32;
    ASSERT_TRUE(StringToNumber("1147483647", &u32));

    char buffer[1024];
    double d = 1.0003;

    ASSERT_STREQ(DoubleToString(d, buffer), "1.0003");
    d = std::numeric_limits<double>::infinity();
    ASSERT_STREQ(DoubleToString(d, buffer), "inf");
    d = -std::numeric_limits<double>::infinity();
    ASSERT_STREQ(DoubleToString(d, buffer), "-inf");
#ifdef __GNUC__ // divided by zero is not allowed in msvc
    d = NAN;
    ASSERT_STREQ(DoubleToString(d, buffer), "nan");
#endif

    float f = 1e+22;
    ASSERT_STREQ(FloatToString(f, buffer), "1e+22");
    f = 0.000325;
    ASSERT_STREQ(FloatToString(f, buffer), "0.000325");
    f = std::numeric_limits<double>::infinity();
    ASSERT_STREQ(FloatToString(f, buffer), "inf");
    f = -std::numeric_limits<double>::infinity();
    ASSERT_STREQ(FloatToString(f, buffer), "-inf");

#ifdef __GNUC__ // divided by zero is not allowed in msvc
    f = NAN;
    ASSERT_STREQ(FloatToString(f, buffer), "nan");

    f = INFINITY;
    ASSERT_STREQ(FloatToString(f, buffer), "inf");
#endif

    f = -std::numeric_limits<float>::infinity();
    ASSERT_STREQ(FloatToString(f, buffer), "-inf");

    uint32_t i = 255;
    ASSERT_STREQ(UInt32ToHexString(i, buffer), "000000ff");

    std::string str = "1110.32505QQ";
    char* endptr;
    ASSERT_TRUE(ParseNumber(str.c_str(), &d, &endptr));
    ASSERT_TRUE(d == 1110.32505);
    ASSERT_FALSE(StringToNumber(str.c_str(), &d));

    ASSERT_TRUE(ParseNumber(str.c_str(), &f, &endptr));
    ASSERT_TRUE(f == 1110.32505f);
    ASSERT_FALSE(StringToNumber(str.c_str(), &f));

    ASSERT_TRUE(ParseNumber(str.c_str(), &i, &endptr));
    ASSERT_EQ(1110U, i);
    ASSERT_FALSE(StringToNumber(str.c_str(), &i));

    str = "1110.32505";
    d = 0;
    f = 0;
    i = 0;
    ASSERT_TRUE(StringToNumber(str.c_str(), &d));
    ASSERT_TRUE(d == 1110.32505);
    ASSERT_TRUE(StringToNumber(str.c_str(), &f));
    ASSERT_TRUE(f == 1110.32505f);
    ASSERT_FALSE(StringToNumber(str.c_str(), &i));
    str = "-1110";
    int32_t x;
    ASSERT_TRUE(StringToNumber(str.c_str(), &x));
    ASSERT_EQ(x, -1110);
}
Ejemplo n.º 11
0
TEST(WTF, StringIsolatedCopy)
{
    String original = "1234";
    auto copy = std::move(original).isolatedCopy();
    ASSERT_FALSE(original.impl() == copy.impl());
}
Ejemplo n.º 12
0
TEST(PalindromeNumber, int_12332){
    Solution *sln = new Solution();
    ASSERT_FALSE(sln->isPalindrome(12332));
}
Ejemplo n.º 13
0
TEST(FunctionBigNumber, EvenBigDecimalNumber)
{
  MyOddWeb::BigNumber x("1234567890987654321123456780.1357997531");
  ASSERT_FALSE(x.IsOdd());
  ASSERT_TRUE(x.IsEven());
}
Ejemplo n.º 14
0
TEST(FunctionBigNumber, OddBigDecimalNumber)
{
  MyOddWeb::BigNumber x("1234567890987654321123456781.2468008642");
  ASSERT_TRUE(x.IsOdd());
  ASSERT_FALSE(x.IsEven());
}
Ejemplo n.º 15
0
TEST(TEST_CASE_LABEL, are_scalar) {
    ASSERT_EQ((are_scalar<E>::value), (are_scalar_v<E>));
    ASSERT_TRUE((are_scalar_v<E>));
    ASSERT_FALSE((are_scalar_v<A*, std::nullptr_t, int, B>));
    ASSERT_TRUE((are_scalar_v<B*, std::nullptr_t, E, void(B::*)()>));
}
Ejemplo n.º 16
0
TEST_F(octtointTest, IllegalCharacter) {
	const char* str = "5ac2";
	u_long actual;

	ASSERT_FALSE(octtoint(str, &actual));
}
Ejemplo n.º 17
0
TEST(TEST_CASE_LABEL, are_compound) {
    ASSERT_EQ((are_compound<int[]>::value), (are_compound_v<int[]>));
    ASSERT_TRUE((are_compound_v<void(*)(int)>));
    ASSERT_FALSE((are_compound_v<A[], char, int(B::*)(char, float)>));
    ASSERT_TRUE((are_compound_v<A[], int(B::*)(char, float), D&, E>));
}
Ejemplo n.º 18
0
TEST_F(octtointTest, IllegalDigit) {
	const char* str = "5283";
	u_long actual;

	ASSERT_FALSE(octtoint(str, &actual));
}
Ejemplo n.º 19
0
TEST(TEST_CASE_LABEL, are_member_pointer) {
    ASSERT_EQ((are_member_pointer<A&&>::value), (are_member_pointer_v<A&&>));
    ASSERT_TRUE((are_member_pointer_v<int(D::*)>));
    ASSERT_FALSE((are_member_pointer_v<void(A::*)(int), B>));
    ASSERT_TRUE((are_member_pointer_v<B(A::*)(D, D), char(B::*)>));
}
Ejemplo n.º 20
0
TEST_F(MindMapModelTest, loadMindMap)
{
	ASSERT_FALSE(Mindmapmodel->loadMindMap("C:\\MindMap\\file_not_exist.mm"));
	ASSERT_TRUE(Mindmapmodel->loadMindMap("..\\test_file.mm"));
}
Ejemplo n.º 21
0
TEST(AllUnknownTests, NonIUnknownTest)
{
    ASSERT_FALSE(dhorn::com::all_unknown_v<std::string>);
}
Ejemplo n.º 22
0
TEST_F(MindMapModelTest, checkMindMapExist)
{
	ASSERT_FALSE(Mindmapmodel->checkMindMapExist());
	Mindmapmodel->createMindMap("Root");
	ASSERT_TRUE(Mindmapmodel->checkMindMapExist());
}
Ejemplo n.º 23
0
TEST(TestMemFile, BadOpenModes) {
  MemFile mf;
  ASSERT_FALSE(mf.open("/some/file1", "+"));
  ASSERT_FALSE(mf.open("/some/file2", "a"));
  ASSERT_FALSE(mf.open("/some/file3", "w"));
}
TEST(MatchExpressionParserGeoNear, ParseInvalidNear) {
    {
        BSONObj query = fromjson("{loc: {$maxDistance: 100, $near: [0,0]}}");
        const CollatorInterface* collator = nullptr;
        StatusWithMatchExpression result =
            MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
        ASSERT_FALSE(result.isOK());
    }
    {
        BSONObj query = fromjson("{loc: {$minDistance: 100, $near: [0,0]}}");
        const CollatorInterface* collator = nullptr;
        StatusWithMatchExpression result =
            MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
        ASSERT_FALSE(result.isOK());
    }
    {
        BSONObj query = fromjson("{loc: {$near: [0,0], $maxDistance: {}}}");
        const CollatorInterface* collator = nullptr;
        ASSERT_THROWS(
            MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator),
            UserException);
    }
    {
        BSONObj query = fromjson("{loc: {$near: [0,0], $minDistance: {}}}");
        const CollatorInterface* collator = nullptr;
        ASSERT_THROWS(
            MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator),
            UserException);
    }
    {
        BSONObj query = fromjson("{loc: {$near: [0,0], $eq: 40}}");
        const CollatorInterface* collator = nullptr;
        ASSERT_THROWS(
            MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator),
            UserException);
    }
    {
        BSONObj query = fromjson("{loc: {$eq: 40, $near: [0,0]}}");
        const CollatorInterface* collator = nullptr;
        StatusWithMatchExpression result =
            MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
        ASSERT_FALSE(result.isOK());
    }
    {
        BSONObj query = fromjson(
            "{loc: {$near: [0,0], $geoWithin: {$geometry: {type: \"Polygon\", coordinates: []}}}}");
        const CollatorInterface* collator = nullptr;
        ASSERT_THROWS(
            MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator),
            UserException);
    }
    {
        BSONObj query = fromjson("{loc: {$near: {$foo: 1}}}");
        const CollatorInterface* collator = nullptr;
        StatusWithMatchExpression result =
            MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
        ASSERT_FALSE(result.isOK());
    }
    {
        BSONObj query = fromjson("{loc: {$minDistance: 10}}");
        const CollatorInterface* collator = nullptr;
        StatusWithMatchExpression result =
            MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
        ASSERT_FALSE(result.isOK());
    }
}
Ejemplo n.º 25
0
TEST_F(BooleanEnumTest, test2)
{
    {
        std::stringstream ss("Initial Content");

        ASSERT_TRUE(ss.good());
        ASSERT_FALSE(ss.fail());
        ASSERT_FALSE(ss.bad());

        BooleanTest t;
        ss >> t;

        ASSERT_FALSE(ss.good());
        ASSERT_FALSE(ss.eof());
        ASSERT_TRUE(ss.fail());
        ASSERT_TRUE(ss.bad());
    }

    {
        std::stringstream ss("BooleanTe");

        ASSERT_TRUE(ss.good());
        ASSERT_FALSE(ss.eof());
        ASSERT_FALSE(ss.fail());
        ASSERT_FALSE(ss.bad());

        BooleanTest t;
        ss >> t;

        ASSERT_FALSE(ss.good());
        ASSERT_TRUE(ss.eof());
        ASSERT_TRUE(ss.fail());
        ASSERT_TRUE(ss.bad());
    }

    {
        std::stringstream ss("BooleanTest::");

        ASSERT_TRUE(ss.good());
        ASSERT_FALSE(ss.eof());
        ASSERT_FALSE(ss.fail());
        ASSERT_FALSE(ss.bad());

        BooleanTest t;
        ss >> t;

        ASSERT_FALSE(ss.good());
        ASSERT_TRUE(ss.eof());
        ASSERT_TRUE(ss.fail());
        ASSERT_TRUE(ss.bad());
    }

    {
        std::stringstream ss("BooleanTest::K");

        ASSERT_TRUE(ss.good());
        ASSERT_FALSE(ss.eof());
        ASSERT_FALSE(ss.fail());
        ASSERT_FALSE(ss.bad());

        BooleanTest t;
        ss >> t;

        ASSERT_FALSE(ss.good());
        ASSERT_FALSE(ss.eof());
        ASSERT_TRUE(ss.fail());
        ASSERT_TRUE(ss.bad());
    }

    {
        std::stringstream ss("BooleanTest::Trump");

        ASSERT_TRUE(ss.good());
        ASSERT_FALSE(ss.eof());
        ASSERT_FALSE(ss.fail());
        ASSERT_FALSE(ss.bad());

        BooleanTest t;
        ss >> t;
        ASSERT_TRUE(ss.good());
        ASSERT_FALSE(ss.eof());
        ASSERT_FALSE(ss.fail());
        ASSERT_FALSE(ss.bad());

        ASSERT_EQ(t, BooleanTest::T);
    }
}
Ejemplo n.º 26
0
TEST_F(
    SyncTailTest,
    MultiApplyDoesNotSetOplogEntryIsForCappedCollectionWhenProcessingNonCappedCollectionInsertOperation) {
    NamespaceString nss("local." + _agent.getSuiteName() + "_" + _agent.getTestName());
    ASSERT_FALSE(_testOplogEntryIsForCappedCollection(_txn.get(), nss, CollectionOptions()));
}
Ejemplo n.º 27
0
CUDA_TEST_P(Hog_var_cell, HOG)
{
    cv::cuda::GpuMat _img(c_img);
    cv::cuda::GpuMat _img2(c_img2);
    cv::cuda::GpuMat _img3(c_img3);
    cv::cuda::GpuMat _img4(c_img4);
    cv::cuda::GpuMat d_img;

    ASSERT_FALSE(_img.empty());
    ASSERT_TRUE(d_img.empty());

    int win_stride_width = 8;int win_stride_height = 8;
    int win_width = 48;
    int block_width = 16;
    int block_stride_width = 8;int block_stride_height = 8;
    int cell_width = 8;
    int nbins = 9;

    Size win_stride(win_stride_width, win_stride_height);
    Size win_size(win_width, win_width * 2);
    Size block_size(block_width, block_width);
    Size block_stride(block_stride_width, block_stride_height);
    Size cell_size(cell_width, cell_width);

    cv::Ptr<cv::cuda::HOG> gpu_hog = cv::cuda::HOG::create(win_size, block_size, block_stride, cell_size, nbins);

    gpu_hog->setNumLevels(13);
    gpu_hog->setHitThreshold(0);
    gpu_hog->setWinStride(win_stride);
    gpu_hog->setScaleFactor(1.05);
    gpu_hog->setGroupThreshold(8);
    gpu_hog->compute(_img, d_img);
//------------------------------------------------------------------------------
    cv::cuda::GpuMat d_img2;
    ASSERT_TRUE(d_img2.empty());

    int win_stride_width2 = 8;int win_stride_height2 = 8;
    int win_width2 = 48;
    int block_width2 = 16;
    int block_stride_width2 = 8;int block_stride_height2 = 8;
    int cell_width2 = 4;

    Size win_stride2(win_stride_width2, win_stride_height2);
    Size win_size2(win_width2, win_width2 * 2);
    Size block_size2(block_width2, block_width2);
    Size block_stride2(block_stride_width2, block_stride_height2);
    Size cell_size2(cell_width2, cell_width2);

    cv::Ptr<cv::cuda::HOG> gpu_hog2 = cv::cuda::HOG::create(win_size2, block_size2, block_stride2, cell_size2, nbins);
    gpu_hog2->setWinStride(win_stride2);
    gpu_hog2->compute(_img, d_img2);
//------------------------------------------------------------------------------
    cv::cuda::GpuMat d_img3;
    ASSERT_TRUE(d_img3.empty());

    int win_stride_width3 = 9;int win_stride_height3 = 9;
    int win_width3 = 54;
    int block_width3 = 18;
    int block_stride_width3 = 9;int block_stride_height3 = 9;
    int cell_width3 = 6;

    Size win_stride3(win_stride_width3, win_stride_height3);
    Size win_size3(win_width3, win_width3 * 2);
    Size block_size3(block_width3, block_width3);
    Size block_stride3(block_stride_width3, block_stride_height3);
    Size cell_size3(cell_width3, cell_width3);

    cv::Ptr<cv::cuda::HOG> gpu_hog3 = cv::cuda::HOG::create(win_size3, block_size3, block_stride3, cell_size3, nbins);
    gpu_hog3->setWinStride(win_stride3);
    gpu_hog3->compute(_img2, d_img3);
//------------------------------------------------------------------------------
    cv::cuda::GpuMat d_img4;
    ASSERT_TRUE(d_img4.empty());

    int win_stride_width4 = 16;int win_stride_height4 = 16;
    int win_width4 = 64;
    int block_width4 = 32;
    int block_stride_width4 = 16;int block_stride_height4 = 16;
    int cell_width4 = 8;

    Size win_stride4(win_stride_width4, win_stride_height4);
    Size win_size4(win_width4, win_width4 * 2);
    Size block_size4(block_width4, block_width4);
    Size block_stride4(block_stride_width4, block_stride_height4);
    Size cell_size4(cell_width4, cell_width4);

    cv::Ptr<cv::cuda::HOG> gpu_hog4 = cv::cuda::HOG::create(win_size4, block_size4, block_stride4, cell_size4, nbins);
    gpu_hog4->setWinStride(win_stride4);
    gpu_hog4->compute(_img3, d_img4);
//------------------------------------------------------------------------------
    cv::cuda::GpuMat d_img5;
    ASSERT_TRUE(d_img5.empty());

    int win_stride_width5 = 16;int win_stride_height5 = 16;
    int win_width5 = 64;
    int block_width5 = 32;
    int block_stride_width5 = 16;int block_stride_height5 = 16;
    int cell_width5 = 16;

    Size win_stride5(win_stride_width5, win_stride_height5);
    Size win_size5(win_width5, win_width5 * 2);
    Size block_size5(block_width5, block_width5);
    Size block_stride5(block_stride_width5, block_stride_height5);
    Size cell_size5(cell_width5, cell_width5);

    cv::Ptr<cv::cuda::HOG> gpu_hog5 = cv::cuda::HOG::create(win_size5, block_size5, block_stride5, cell_size5, nbins);
    gpu_hog5->setWinStride(win_stride5);
    gpu_hog5->compute(_img3, d_img5);
//------------------------------------------------------------------------------
}
Ejemplo n.º 28
0
TEST(TestUtilities, GetAttribute)
{
  TiXmlDocument doc;
  doc.LoadFile("src/Utility/Test/refdata/getattribute.xml");
  ASSERT_TRUE(doc.RootElement());

  const char* bTrue[4]  = { "booltrue" , "boolone" , "boolon" , "boolyes" };
  const char* bFalse[4] = { "boolfalse", "boolzero", "booloff", "boolno"  };

  int i;
  for (i = 0; i < 4; i++) {
    const TiXmlElement* elem = doc.RootElement()->FirstChildElement(bTrue[i]);
    ASSERT_TRUE(elem != nullptr);
    bool b = false;
    ASSERT_TRUE(utl::getAttribute(elem, "bar", b));
    ASSERT_TRUE(b);
  }

  for (i = 0; i < 4; i++) {
    const TiXmlElement* elem = doc.RootElement()->FirstChildElement(bFalse[i]);
    ASSERT_TRUE(elem != nullptr);
    bool b = false;
    ASSERT_TRUE(utl::getAttribute(elem, "bar", b));
    ASSERT_FALSE(b);
  }

  const TiXmlElement* elem = doc.RootElement()->FirstChildElement("intval");
  ASSERT_TRUE(elem != nullptr);
  int val1 = 0;
  ASSERT_TRUE(utl::getAttribute(elem, "bar", val1));
  ASSERT_EQ(val1, 1);
  size_t val2 = 0;
  ASSERT_TRUE(utl::getAttribute(elem, "bar", val2));
  ASSERT_EQ(val2, 1U);

  elem = doc.RootElement()->FirstChildElement("realval");
  ASSERT_TRUE(elem != nullptr);
  double val3 = 0.0;
  ASSERT_TRUE(utl::getAttribute(elem, "bar", val3));
  ASSERT_FLOAT_EQ(val3, 2.01);

  elem = doc.RootElement()->FirstChildElement("vecval1");
  ASSERT_TRUE(elem != nullptr);
  Vec3 val4;
  ASSERT_TRUE(utl::getAttribute(elem, "bar", val4));
  ASSERT_FLOAT_EQ(val4.x, 1.2);
  ASSERT_FLOAT_EQ(val4.y, 0.0);
  ASSERT_FLOAT_EQ(val4.z, 0.0);
  ASSERT_TRUE(utl::getAttribute(elem, "bar", val4, 2));
  ASSERT_FLOAT_EQ(val4.x, 1.2);
  ASSERT_FLOAT_EQ(val4.y, 1.2);
  ASSERT_FLOAT_EQ(val4.z, 0.0);
  ASSERT_TRUE(utl::getAttribute(elem, "bar", val4, 3));
  ASSERT_FLOAT_EQ(val4.x, 1.2);
  ASSERT_FLOAT_EQ(val4.y, 1.2);
  ASSERT_FLOAT_EQ(val4.z, 1.2);

  elem = doc.RootElement()->FirstChildElement("vecval2");
  ASSERT_TRUE(elem != nullptr);
  ASSERT_TRUE(utl::getAttribute(elem, "bar", val4));
  ASSERT_FLOAT_EQ(val4.x, 1.2);
  ASSERT_FLOAT_EQ(val4.y, 3.4);
  ASSERT_FLOAT_EQ(val4.z, 0.0);
  ASSERT_TRUE(utl::getAttribute(elem, "bar", val4, 2));
  ASSERT_FLOAT_EQ(val4.x, 1.2);
  ASSERT_FLOAT_EQ(val4.y, 3.4);
  ASSERT_FLOAT_EQ(val4.z, 0.0);
  ASSERT_TRUE(utl::getAttribute(elem, "bar", val4, 3));
  ASSERT_FLOAT_EQ(val4.x, 1.2);
  ASSERT_FLOAT_EQ(val4.y, 3.4);
  ASSERT_FLOAT_EQ(val4.z, 3.4);

  elem = doc.RootElement()->FirstChildElement("vecval3");
  ASSERT_TRUE(elem != nullptr);
  ASSERT_TRUE(utl::getAttribute(elem, "bar", val4));
  ASSERT_FLOAT_EQ(val4.x, 1.2);
  ASSERT_FLOAT_EQ(val4.y, 3.4);
  ASSERT_FLOAT_EQ(val4.z, 5.6);
  ASSERT_TRUE(utl::getAttribute(elem, "bar", val4, 2));
  ASSERT_FLOAT_EQ(val4.x, 1.2);
  ASSERT_FLOAT_EQ(val4.y, 3.4);
  ASSERT_FLOAT_EQ(val4.z, 0.0);
  ASSERT_TRUE(utl::getAttribute(elem, "bar", val4, 3));
  ASSERT_FLOAT_EQ(val4.x, 1.2);
  ASSERT_FLOAT_EQ(val4.y, 3.4);
  ASSERT_FLOAT_EQ(val4.z, 5.6);
}
Ejemplo n.º 29
0
void FileV3Test::TearDown()
{
  ASSERT_TRUE(pws_os::DeleteAFile(fname));
  ASSERT_FALSE(pws_os::FileExists(fname));
}
Ejemplo n.º 30
0
TEST(FunctionBigNumber, OddDecimalNumber)
{
  MyOddWeb::BigNumber x(1235.246);
  ASSERT_TRUE(x.IsOdd());
  ASSERT_FALSE(x.IsEven());
}