Пример #1
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])));
    }
}
Пример #2
0
IUTEST(SyntaxTest, False)
{
    if( bool b = false )
        IUTEST_ASSERT_FALSE(b) << b;
    if( bool b = false )
        IUTEST_EXPECT_FALSE(b) << b;
    if( bool b = false )
        IUTEST_INFORM_FALSE(b) << b;
    if( bool b = false )
        IUTEST_ASSUME_FALSE(b) << b;
}
Пример #3
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);
    }
}
Пример #4
0
IUTEST(UnitEnvTest, GetEnvironmentVariable)
{
    char buf[2];
    IUTEST_EXPECT_FALSE(::iutest::detail::GetEnvironmentVariable("PATH", buf, sizeof(buf)));
    IUTEST_EXPECT_FALSE(::iutest::detail::GetEnvironmentVariable("PATH", NULL, 0));
}