示例#1
0
TEST(Lambda, for_each_loop_without_lambda) {
    struct adder {
        adder(int & external_data) :
            m_total(external_data)
        {}

        void operator()(int value) {
            m_total += value;
        }

        int & m_total;
    };

    int total = 0;
    std::vector<int> vec;

    adder sum(total);
    vec.push_back( 1 );
    vec.push_back( 2 );

    std::for_each(vec.begin(), vec.end(), sum);
    ASSERT_THAT(total, ::testing::Eq(3));
}
示例#2
0
        TEST_F(DBTableTest, next_row) {

            std::string fieldName = "fieldName";
            createTable(tableName, {"a integer, b integer"});
            insertTable(tableName, "1, 3");
            insertTable(tableName, "10, 30");
            insertTable(tableName, "100, 300");

            dbTable = std::make_shared<DBTable>(tableName);

            auto row1 = dbTable->find("");
            ASSERT_THAT(row1->getValue("b"), IsAnyInteger(3));
            auto row2 = dbTable->nextRow();
            ASSERT_THAT((bool) row2, true);
            ASSERT_THAT(row2->getValue("b"), IsAnyInteger(30));
            auto row3 = dbTable->nextRow();
            ASSERT_THAT((bool) row3, true);
            ASSERT_THAT(row3->getValue("b"), IsAnyInteger(300));
            auto row4 = dbTable->nextRow();
            ASSERT_THAT((bool) row4, false);
        }
示例#3
0
文件: main.cpp 项目: hansmaad/Mint
TEST_CASE(IntTest, Plus)
{
    int result = 1 + 2;
    ASSERT_THAT(result, Is.EqualTo(4));
}
示例#4
0
TEST_F( ZDevicesTest, at_begin_return_empty) {
	ptree properties = zDevices->getDifferences(0);
	ASSERT_THAT(properties.size(), Eq(0));
}
示例#5
0
TEST ( Heapsort, alternating )
{
    std::vector<int> numbers_alternating { 1, 3, 2, 4, 3, 5, 4, 6, 5 };
    AP::algorithms::heapsort( begin(numbers_alternating), end(numbers_alternating) );
    ASSERT_THAT( numbers_alternating, ::testing::ElementsAre( 1, 2, 3, 3, 4, 4, 5, 5, 6 )  );
}
示例#6
0
TEST( BowlingKata, full_play )
{
    ASSERT_THAT( bowling( "3/X-5/321/X-X-3/3145" ), Eq(147));
}
示例#7
0
TEST( BowlingKata, strike_and_next_two_plays )
{
    ASSERT_THAT( bowling( "X-54" ), Eq( 28 ) );
}
示例#8
0
TEST( BowlingKata, strike_hifen )
{
    ASSERT_THAT( bowling( "X-" ), Eq( 10 ) );
}
示例#9
0
TEST( BowlingKata, strike )
{
    ASSERT_THAT( bowling( "X" ), Eq( 10 ) );
}
示例#10
0
    TestResult result;

    TestCaseTest()
    {
        result.add(collector);
    }

    template <typename Functor>
    void run_test(Functor f)
    {
        FakeTestCase(f).runBare(result);
    }

    TEST("when test case assert success")
    {
        run_test([] { ASSERT_THAT(1, is(1)); });
        ASSERT_THAT(collector->numOfFail, is(0));
    }

    TEST("when test case assert fail")
    {
        run_test([] { ASSERT_THAT(1, is(2)); });
        ASSERT_THAT(collector->numOfFail, is(1));
        ASSERT_THAT(collector->numOfFailure, is(1));
    }

    TEST("when test case throw std::exception")
    {
        run_test([] { throw std::exception(); });
        ASSERT_THAT(collector->numOfFail, is(1));
        ASSERT_THAT(collector->numOfError, is(1));
TEST(BraceInitialization, SupportsArrays) {
    int iArray[] {1, 1, 2, 3, 5, 8};
    ASSERT_THAT(iArray, ::testing::ElementsAre(1, 1, 2, 3, 5, 8));
}
TEST(BraceInitialization, SupportsCollectionTypes) {
    std::vector<std::string> strNames {"alpha", "beta", "gamma" };
    ASSERT_THAT(strNames, ::testing::ElementsAre("alpha", "beta", "gamma"));
}
TEST(BraceInitialization, SupportsStrings) {
    std::string strValue{"Stefan"};
    ASSERT_THAT(strValue, ::testing::Eq("Stefan"));
}
TEST(BraceInitialization, IsProbablyNotWhatYouWantWhenUsingAuto) {
    auto x{9};
    ASSERT_THAT(x, ::testing::A<const std::initializer_list<int>>());
    // in other words, the following assignment passes compilation. Thus x is *not* an int.
    const std::initializer_list<int> y = x;
}
TEST(BraceInitialization, CanIncludeEqualsSign) {
   int i = {99};
   ASSERT_THAT(i, ::testing::Eq(99));
}
示例#16
0
TEST( BowlingKata, spare_and_next_play )
{
    ASSERT_THAT( bowling( "3/6" ), Eq( 22 ) );
}
示例#17
0
TEST( BowlingKata, two_spares )
{
    ASSERT_THAT( bowling( "3/6/2" ), Eq( 30 ) );
}
示例#18
0
 void then_result_is(const std::string& result)
 {
     ASSERT_THAT(desc.to_s(), is(result));
 }
示例#19
0
TEST( BowlingKata, one_ball )
{
    ASSERT_THAT( bowling( "3" ), Eq( 3 ) );
}
TEST_F(ClangQueryGatherer, StartCreateSourceRangesForNextSourcePopsSource)
{
    manyGatherer.startCreateNextSourceRangesMessage();

    ASSERT_THAT(manyGatherer.sources(), SizeIs(2));
}
示例#21
0
TEST( BowlingKata, strike_and_next_play )
{
    ASSERT_THAT( bowling( "X-5" ), Eq( 20 ) );
}
TEST_F(ClangQueryGatherer, AfterStartCreateSourceRangesMessagesFutureCountIsTwos)
{
    manyGatherer.startCreateNextSourceRangesMessages();

    ASSERT_THAT(manyGatherer.sourceFutures(), SizeIs(2));
}
示例#23
0
TEST( BowlingKata, strike_and_spare )
{
    ASSERT_THAT( bowling( "X-5/" ), Eq( 30 ) );
}
TEST(MapFilterReduce, Reduce1)
{
  vector<double> v{ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };
  auto res = accumulate(v.begin(), v.end(), 0.0, adder());
  ASSERT_THAT(res, DoubleEq(21.0));
}
示例#25
0
TEST( BowlingKata, two_balls )
{
    ASSERT_THAT( bowling( "31" ), Eq( 4 ) );
}
示例#26
0
TEST( BowlingKata, two_balls_3_2 )
{
    ASSERT_THAT( bowling( "32" ), Eq( 5 ) );
}
示例#27
0
TEST_F(NotesRepositoryTest, FirstTest)
{
    std::vector<Model::Note> notes = m_notesRepository.GetNotes();
    ASSERT_THAT(notes.size(), 10);
}
示例#28
0
TEST( BowlingKata, five_balls )
{
    ASSERT_THAT( bowling( "32791" ), Eq( 22 ) );
}
示例#29
0
TEST(ShellSort, UpToTen) {
  int input[] = {10, 8, 4, 6, 7, 1, 2, 9, 5, 3};
  sort(input, 10);

  ASSERT_THAT(input, testing::ElementsAre(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
}
示例#30
0
TEST( BowlingKata, one_spare )
{
    ASSERT_THAT( bowling( "3/" ), Eq( 10 ) );
}