awtk/tests/rect_test.cc

25 lines
609 B
C++
Raw Normal View History

2018-06-27 13:46:42 +08:00
#include "base/rect.h"
2018-02-21 19:36:38 +08:00
#include "gtest/gtest.h"
TEST(Rect, merge) {
rect_t dr;
rect_t r;
2018-06-22 12:01:36 +08:00
dr = rect_init(50, 240, 80, 30);
r = rect_init(50, 200, 80, 30);
2018-02-21 19:36:38 +08:00
ASSERT_EQ(rect_merge(&dr, &r), RET_OK);
ASSERT_EQ(dr.x, 50);
ASSERT_EQ(dr.y, 200);
ASSERT_EQ(dr.h, 70);
ASSERT_EQ(dr.w, 80);
}
2018-04-02 17:35:20 +08:00
TEST(Rect, contains) {
rect_t r;
2018-06-22 12:01:36 +08:00
r = rect_init(50, 200, 80, 30);
2018-04-02 17:35:20 +08:00
ASSERT_EQ(rect_contains(&r, 50, 200), TRUE);
ASSERT_EQ(rect_contains(&r, 55, 200), TRUE);
2018-04-05 17:09:29 +08:00
ASSERT_EQ(rect_contains(&r, 55, 220), TRUE);
2018-04-02 17:35:20 +08:00
ASSERT_EQ(rect_contains(&r, 5, 24), FALSE);
ASSERT_EQ(rect_contains(&r, 5, 240), FALSE);
}