Example #1
0
IUTEST(ReturnTest, Test)
{
    IUTEST_ASSERT_FATAL_FAILURE(ReturnTestCall(), "");
#if IUTEST_USE_THROW_ON_ASSERTION_FAILURE
    IUTEST_EXPECT_EQ( 1, value1);
    IUTEST_EXPECT_EQ( 1, value2);
#else
    IUTEST_EXPECT_EQ(-1, value1);
    IUTEST_EXPECT_EQ(-1, value2);
#endif
}
Example #2
0
int main(int argc, char* argv[])
#endif
{
    IUTEST_INIT(&argc, argv);

    IUTEST_EXPECT_EQ(0, 1);

    {
        const int ret = IUTEST_RUN_ALL_TESTS();
        if( ret == 0 ) return 1;
    }
    {
        const int ret = IUTEST_RUN_ALL_TESTS();
        if( ret == 0 ) return 1;
    }
#if !defined(IUTEST_USE_GTEST)
    {
        IUTEST_INIT(&argc, argv);
        const int ret = IUTEST_RUN_ALL_TESTS();
        if( ret != 0 ) return 1;
    }
#endif
    printf("*** Successful ***\n");
    return 0;
}
Example #3
0
IUTEST(DISABLED_TestFailure, Mix)
{
    IUTEST_EXPECT_EQ(0.1, 1);
    IUTEST_EXPECT_NE(0, 0);
    IUTEST_EXPECT_LE(2, 0);
    IUTEST_EXPECT_LT(0, 0);
    IUTEST_EXPECT_GE(0, 2);
    IUTEST_EXPECT_GT(0, 0);
    IUTEST_EXPECT_TRUE(0);
    IUTEST_EXPECT_FALSE(1);
    IUTEST_EXPECT_FLOAT_EQ(0.0f, 0.1f);
    IUTEST_EXPECT_DOUBLE_EQ(0.0, 0.1);
    IUTEST_EXPECT_NEAR(0, 100, 2);
    IUTEST_EXPECT_FAIL();
    {
        ::std::string str1 = "test";
        ::std::string str2 = "text";

        IUTEST_EXPECT_STREQ("text", str1);
        IUTEST_EXPECT_STRNE("text", str2);
        IUTEST_EXPECT_STRCASEEQ("Text", str1);
        IUTEST_EXPECT_STRCASENE("Text", str2);
    }
    // EQ_COLLECTIONS
    {
        int  aa[] = { 0, 1, 2, 3, 4 };
        int  ab[] = { 0, 1, 2, 3, 4, 5 };
        char ac[] = { 0, 0, 2, 3, 5 };
        IUTEST_EXPECT_EQ_COLLECTIONS(aa, aa+(sizeof(aa)/sizeof(aa[0])), ab, ab+(sizeof(ab)/sizeof(ab[0])));
        IUTEST_EXPECT_EQ_COLLECTIONS(ab, ab+(sizeof(ab)/sizeof(ab[0])), aa, aa+(sizeof(aa)/sizeof(aa[0])));
        IUTEST_EXPECT_EQ_COLLECTIONS(aa, aa+(sizeof(aa)/sizeof(aa[0])), ac, ac+(sizeof(ac)/sizeof(ac[0])));
    }
}
Example #4
0
	IUTEST_P(ParamTest, Eq)
	{
		IUTEST_ASSERT_EQ(0, GetParam());
		IUTEST_EXPECT_EQ(0, GetParam());
		IUTEST_INFORM_EQ(0, GetParam());
		IUTEST_ASSUME_EQ(0, GetParam());
	}
Example #5
0
IUTEST_TYPED_TEST(FloatingpointTest, NQNAN)
{
    typedef typename TestFixture::ftype FloatType;
    TypeParam a=TestFixture::ONE;

    IUTEST_EXPECT_EQ(FloatType(sqrt(-a)), TestFixture::ftype::NQNAN());
}
Example #6
0
IUTEST_TYPED_TEST(FloatingpointTest, NINF)
{
    typedef typename TestFixture::ftype FloatType;
    TypeParam b=TestFixture::ZERO;

    IUTEST_EXPECT_EQ(FloatType(log(b)), TestFixture::ftype::NINF());
}
Example #7
0
IUTEST_TYPED_TEST(FloatingpointTest, PINF)
{
    typedef typename TestFixture::ftype FloatType;
    TypeParam a=TestFixture::ONE;
    TypeParam b=TestFixture::ZERO;

    IUTEST_EXPECT_EQ(FloatType(a/b), TestFixture::ftype::PINF());
}
Example #8
0
IUTEST(SyntaxTest, EQ)
{
    if( int x = 1 )
        IUTEST_ASSERT_EQ(1, x) << x;
    if( int x = 1 )
        IUTEST_EXPECT_EQ(1, x) << x;
    if( int x = 1 )
        IUTEST_INFORM_EQ(1, x) << x;
    if( int x = 1 )
        IUTEST_ASSUME_EQ(1, x) << x;
}
Example #9
0
IUTEST(FlagTest, Check)
{
    IUTEST_ASSERT_TRUE( listener->called_OnTestProgramStart );
    IUTEST_ASSERT_TRUE( listener->called_OnTestIterationStart );
    IUTEST_ASSERT_TRUE( listener->called_OnEnvironmentsSetUpStart );
    IUTEST_ASSERT_TRUE( listener->called_OnEnvironmentsSetUpEnd );
    IUTEST_ASSERT_TRUE( listener->called_OnTestCaseStart );
    IUTEST_ASSERT_TRUE( listener->called_OnTestStart );

    IUTEST_ASSERT_FALSE( listener->called_OnTestEnd );
    IUTEST_ASSERT_FALSE( listener->called_OnTestCaseEnd );
    IUTEST_ASSERT_FALSE( listener->called_OnEnvironmentsTearDownStart );
    IUTEST_ASSERT_FALSE( listener->called_OnEnvironmentsTearDownEnd );
    IUTEST_ASSERT_FALSE( listener->called_OnTestIterationEnd );
    IUTEST_ASSERT_FALSE( listener->called_OnTestProgramEnd );

    IUTEST_ASSERT_FALSE( listener->called_OnTestPartResult );
    IUTEST_EXPECT_EQ(1, 2);
    IUTEST_ASSERT_TRUE( listener->called_OnTestPartResult );

    IUTEST_ASSERT_FALSE( listener->called_OnTestRecordProperty );
    RecordProperty("dummy", 0);
    IUTEST_ASSERT_TRUE( listener->called_OnTestRecordProperty );
}
Example #10
0
IUTEST(AssertionTest, String)
{
    const char mbs[] = "test";
    const wchar_t wcs[] = L"test";
    IUTEST_EXPECT_STREQ( "test", mbs);
    IUTEST_EXPECT_STREQ(L"test", wcs);

    IUTEST_EXPECT_STRNE( "host", mbs);
    IUTEST_EXPECT_STRNE(L"host", wcs);

    IUTEST_EXPECT_STRLNEQ(4, mbs);
    IUTEST_EXPECT_STRLNEQ(4, wcs);

    {
        ::std::string str1 = "test";
        IUTEST_EXPECT_EQ(str1, "test");

        IUTEST_EXPECT_NE(str1, "host");
    }

    {
        ::std::string str1 = "tEst";
        ::std::string str2 = "teSt";
        ::std::string str3 = "hoSt";

        IUTEST_EXPECT_STRCASEEQ("TeSt", mbs);
        IUTEST_EXPECT_STRCASEEQ("TeSt", str1);
        IUTEST_EXPECT_STRCASEEQ(str1, "TeSt");
        IUTEST_EXPECT_STRCASEEQ(str1, str2);

        IUTEST_EXPECT_STRCASENE("HoSt", mbs);
        IUTEST_EXPECT_STRCASENE("HoSt", str1);
        IUTEST_EXPECT_STRCASENE(str1, "HoSt");
        IUTEST_EXPECT_STRCASENE(str1, str3);
    }
}
Example #11
0
IUTEST(AssertionTest, Base)
{
    int x0=0, y0=0, x1=1;
    float f0=0.0f, f1=1.0f;
    double d0=0.0, d1=1.0;

    IUTEST_ASSUME_EQ(x0, y0);

    // true/false
    {
        IUTEST_EXPECT_TRUE(true);
        IUTEST_EXPECT_TRUE(1);
        IUTEST_EXPECT_TRUE(100==100);

        IUTEST_EXPECT_FALSE(false);
        IUTEST_EXPECT_FALSE(0);
        IUTEST_EXPECT_FALSE(100!=100);
    }
    // EQ
    {
        IUTEST_EXPECT_EQ(x0, y0);
        int* zero=NULL;
        IUTEST_EXPECT_EQ(NULL, zero);

        ::std::vector<int> v1, v2;
        IUTEST_EXPECT_EQ(v1, v2);
    }
    // EQ_COLLECTIONS
    {
        int a[] = { 0, 1, 2, 3 };
        int b[] = { 0, 1, 2, 3 };
        IUTEST_ASSERT_EQ_COLLECTIONS(a, a+4, b, b+4);
    }

    // NE
    {
        IUTEST_EXPECT_NE(x0, x1);
        int* one=reinterpret_cast<int*>(1);
        IUTEST_EXPECT_NE(NULL, one);
    }

    // LE, LT
    {
        IUTEST_EXPECT_LE(x0, y0);
        IUTEST_EXPECT_LE(f0, f1);
        IUTEST_EXPECT_LE(0.0, 0x1);
        IUTEST_EXPECT_LT(x0, x1);
        IUTEST_EXPECT_LT(d0, d1);
        IUTEST_EXPECT_LT(0.0, 0x1);
    }

    // GE, GT
    {
        IUTEST_EXPECT_GE(x0, y0);
        IUTEST_EXPECT_GE(f1, f0);
        IUTEST_EXPECT_GE(0x1, 0.0f);
        IUTEST_EXPECT_GT(x1, x0);
        IUTEST_EXPECT_GT(d1, d0);
        IUTEST_EXPECT_GT(0x1, 0.0f);
    }

    // float. double
    {
        IUTEST_EXPECT_FLOAT_EQ(1.0f, f1);
        IUTEST_EXPECT_FLOAT_EQ(0.0f, f0);
        IUTEST_EXPECT_FLOAT_EQ(-1.0f, -2.0f/2.0f);

        IUTEST_EXPECT_DOUBLE_EQ(1.0, d1);
        IUTEST_EXPECT_DOUBLE_EQ(0.0, d0);
        IUTEST_EXPECT_DOUBLE_EQ(-1.0, -2.0/2.0);
    }

    // Near
    {
        IUTEST_EXPECT_NEAR(0, 1, 2);
        IUTEST_EXPECT_NEAR(1.0f, 4.0f, 4);
        IUTEST_EXPECT_NEAR(2.0, 1.0, 2);
    }
}
Example #12
0
IUTEST(Foo, Bar)
{
    IUTEST_EXPECT_EQ(0, 1);
}
Example #13
0
IUTEST(UnitAnyTest, String)
{
    ::iutest::any a = "test";
    IUTEST_EXPECT_EQ("test", ::iutest::any_cast< ::std::string >(a));
}
Example #14
0
 ~TestFixtureLikeVCUnit()
 {
     IUTEST_EXPECT_EQ(3, x);
 }
IUTEST(Expect, Test)
{
    IUTEST_EXPECT_EQ(2, 1);
}
Example #16
0
IUTEST(Foo, Test)
{
    IUTEST_EXPECT_EQ(0, x);
}