Add HB_DIRECTION_IS_VALID

This commit is contained in:
Behdad Esfahbod 2012-04-14 19:19:26 -04:00
parent 5e88aa6682
commit fe28b997fb
2 changed files with 8 additions and 0 deletions

View File

@ -118,6 +118,7 @@ hb_direction_to_string (hb_direction_t direction);
#define HB_DIRECTION_IS_VERTICAL(dir) ((((unsigned int) (dir)) & ~1U) == 6)
#define HB_DIRECTION_IS_FORWARD(dir) ((((unsigned int) (dir)) & ~2U) == 4)
#define HB_DIRECTION_IS_BACKWARD(dir) ((((unsigned int) (dir)) & ~2U) == 5)
#define HB_DIRECTION_IS_VALID(dir) ((((unsigned int) (dir)) & ~3U) == 4)
#define HB_DIRECTION_REVERSE(dir) ((hb_direction_t) (((unsigned int) (dir)) ^ 1))

View File

@ -78,6 +78,13 @@ test_types_direction (void)
g_assert (HB_DIRECTION_IS_BACKWARD (HB_DIRECTION_BTT));
g_assert (!HB_DIRECTION_IS_BACKWARD (HB_DIRECTION_INVALID));
g_assert (HB_DIRECTION_IS_VALID (HB_DIRECTION_LTR));
g_assert (HB_DIRECTION_IS_VALID (HB_DIRECTION_TTB));
g_assert (HB_DIRECTION_IS_VALID (HB_DIRECTION_RTL));
g_assert (HB_DIRECTION_IS_VALID (HB_DIRECTION_BTT));
g_assert (!HB_DIRECTION_IS_VALID (HB_DIRECTION_INVALID));
g_assert (!HB_DIRECTION_IS_VALID ((hb_direction_t) 0x12345678));
g_assert_cmpint (HB_DIRECTION_REVERSE (HB_DIRECTION_LTR), ==, HB_DIRECTION_RTL);
g_assert_cmpint (HB_DIRECTION_REVERSE (HB_DIRECTION_RTL), ==, HB_DIRECTION_LTR);
g_assert_cmpint (HB_DIRECTION_REVERSE (HB_DIRECTION_TTB), ==, HB_DIRECTION_BTT);