mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-04-04 21:30:38 +02:00
test: add a unit test for ei_region_convert_point
This commit is contained in:
parent
059d3e11b6
commit
22079d62dc
1 changed files with 28 additions and 0 deletions
|
|
@ -142,4 +142,32 @@ MUNIT_TEST(test_region_contains)
|
|||
|
||||
return MUNIT_OK;
|
||||
}
|
||||
|
||||
MUNIT_TEST(test_region_convert)
|
||||
{
|
||||
struct ei_region r = {0};
|
||||
|
||||
ei_region_set_size(&r, 640, 480);
|
||||
ei_region_set_offset(&r, 100, 200);
|
||||
|
||||
double x = 100;
|
||||
double y = 200;
|
||||
munit_assert_true(ei_region_convert_point(&r, &x, &y));
|
||||
munit_assert_double_equal(x, 0, 4 /* precision */);
|
||||
munit_assert_double_equal(y, 0, 4 /* precision */);
|
||||
|
||||
x = 101.2;
|
||||
y = 202.3;
|
||||
munit_assert_true(ei_region_convert_point(&r, &x, &y));
|
||||
munit_assert_double_equal(x, 1.2, 4 /* precision */);
|
||||
munit_assert_double_equal(y, 2.3, 4 /* precision */);
|
||||
|
||||
x = 99.9;
|
||||
y = 199.9;
|
||||
munit_assert_false(ei_region_convert_point(&r, &x, &y));
|
||||
munit_assert_double_equal(x, 99.9, 4 /* precision */);
|
||||
munit_assert_double_equal(y, 199.9, 4 /* precision */);
|
||||
|
||||
return MUNIT_OK;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue