Ejemplo n.º 1
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
TEST(RectTest, IncludeRect)
{
    Rectd rect;
    {
        Rectd otherRect(10, 20, 5, 15);
        rect.include(otherRect);

        EXPECT_DOUBLE_EQ(0.0, rect.min().x());
        EXPECT_DOUBLE_EQ(0.0, rect.min().y());
        EXPECT_DOUBLE_EQ(15, rect.width());
        EXPECT_DOUBLE_EQ(35, rect.height());
    }

    {
        Rectd otherRect(-10, -20, 5, 5);
        rect.include(otherRect);

        EXPECT_DOUBLE_EQ(-10, rect.min().x());
        EXPECT_DOUBLE_EQ(-20, rect.min().y());
        EXPECT_DOUBLE_EQ(25, rect.width());
        EXPECT_DOUBLE_EQ(55, rect.height());
    }

    {
        Rectd otherRect(-100, -200, 200, 300);
        rect.include(otherRect);

        EXPECT_DOUBLE_EQ(-100, rect.min().x());
        EXPECT_DOUBLE_EQ(-200, rect.min().y());
        EXPECT_DOUBLE_EQ(200, rect.width());
        EXPECT_DOUBLE_EQ(300, rect.height());
    }
}
Ejemplo n.º 2
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
TEST(RectTest, Include)
{
    {
        Rectd rect;
        Vec2d pt1(10, 20);
        rect.include(pt1);

        EXPECT_DOUBLE_EQ(0.0, rect.min().x());
        EXPECT_DOUBLE_EQ(0.0, rect.min().y());
        EXPECT_DOUBLE_EQ(10, rect.width());
        EXPECT_DOUBLE_EQ(20, rect.height());

        Vec2d pt2(20, 30);
        rect.include(pt2);

        EXPECT_DOUBLE_EQ(0, rect.min().x());
        EXPECT_DOUBLE_EQ(0, rect.min().y());
        EXPECT_DOUBLE_EQ(20, rect.width());
        EXPECT_DOUBLE_EQ(30, rect.height());
    }

    {
        Rectd rect;
        Vec2d pt1(10, 20);
        rect.setMin(pt1);

        EXPECT_DOUBLE_EQ(10, rect.min().x());
        EXPECT_DOUBLE_EQ(20, rect.min().y());
        EXPECT_DOUBLE_EQ(0, rect.width());
        EXPECT_DOUBLE_EQ(0, rect.height());

        Vec2d pt2(20, 30);
        rect.include(pt2);

        EXPECT_DOUBLE_EQ(10, rect.min().x());
        EXPECT_DOUBLE_EQ(20, rect.min().y());
        EXPECT_DOUBLE_EQ(10, rect.width());
        EXPECT_DOUBLE_EQ(10, rect.height());

        Vec2d pt3(-20, -30);
        rect.include(pt3);

        EXPECT_DOUBLE_EQ(-20, rect.min().x());
        EXPECT_DOUBLE_EQ(-30, rect.min().y());
        EXPECT_DOUBLE_EQ(40, rect.width());
        EXPECT_DOUBLE_EQ(60, rect.height());
    }
}