aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-01-21 12:27:15 +0100
committerMattias Andrée <maandree@kth.se>2023-01-21 12:27:20 +0100
commitd475736b3a32e1abaf47f5e7dfd403bfd7848f2b (patch)
tree7c91deb31f49ead461ae18ca7a1ef684d3b21a95
parentAdd libfonts_get_subpixel_expansion (diff)
downloadlibfonts-d475736b3a32e1abaf47f5e7dfd403bfd7848f2b.tar.gz
libfonts-d475736b3a32e1abaf47f5e7dfd403bfd7848f2b.tar.bz2
libfonts-d475736b3a32e1abaf47f5e7dfd403bfd7848f2b.tar.xz
Add tests for libfonts_get_subpixel_expansion
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--libfonts_get_subpixel_expansion.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/libfonts_get_subpixel_expansion.c b/libfonts_get_subpixel_expansion.c
index 99f72ba..e63d729 100644
--- a/libfonts_get_subpixel_expansion.c
+++ b/libfonts_get_subpixel_expansion.c
@@ -45,6 +45,64 @@ libfonts_get_subpixel_expansion(enum libfonts_subpixel_order_class layout, size_
int
main(void)
{
+ size_t w, h;
+
+#define T(L)\
+ do {\
+ errno = 0;\
+ ASSERT(libfonts_get_subpixel_expansion(L, NULL, NULL) == -1);\
+ ASSERT(errno == EINVAL);\
+ \
+ errno = 0;\
+ ASSERT(libfonts_get_subpixel_expansion(L, &w, NULL) == -1);\
+ ASSERT(errno == EINVAL);\
+ \
+ errno = 0;\
+ ASSERT(libfonts_get_subpixel_expansion(L, NULL, &h) == -1);\
+ ASSERT(errno == EINVAL);\
+ \
+ errno = 0;\
+ ASSERT(libfonts_get_subpixel_expansion(L, &w, &h) == -1);\
+ ASSERT(errno == EINVAL);\
+ } while (0)
+
+ T(LIBFONTS_SUBPIXEL_ORDER_CLASS_OTHER);
+ T((enum libfonts_subpixel_order_class)999);
+
+#undef T
+
+#define T(L, W, H)\
+ do {\
+ w = 0, h = 0;\
+ ASSERT(!libfonts_get_subpixel_expansion(L, NULL, NULL));\
+ \
+ w = 0, h = 0;\
+ ASSERT(!libfonts_get_subpixel_expansion(L, &w, NULL));\
+ ASSERT(w == (W));\
+ \
+ w = 0, h = 0;\
+ ASSERT(!libfonts_get_subpixel_expansion(L, NULL, &h));\
+ ASSERT(h == (H));\
+ \
+ w = 0, h = 0;\
+ ASSERT(!libfonts_get_subpixel_expansion(L, &w, &h));\
+ ASSERT(w == (W));\
+ ASSERT(h == (H));\
+ } while (0)
+
+ errno = EDOM;
+ T(LIBFONTS_SUBPIXEL_ORDER_CLASS_123, 3, 1);
+ T(LIBFONTS_SUBPIXEL_ORDER_CLASS_1_2_3, 1, 3);
+ T(LIBFONTS_SUBPIXEL_ORDER_CLASS_11_23, 2, 2);
+ T(LIBFONTS_SUBPIXEL_ORDER_CLASS_21_31, 2, 2);
+ T(LIBFONTS_SUBPIXEL_ORDER_CLASS_32_11, 2, 2);
+ T(LIBFONTS_SUBPIXEL_ORDER_CLASS_13_12, 2, 2);
+ T(LIBFONTS_SUBPIXEL_ORDER_CLASS_BALANCED_11_23, 2, 3);
+ T(LIBFONTS_SUBPIXEL_ORDER_CLASS_BALANCED_21_31, 3, 2);
+ T(LIBFONTS_SUBPIXEL_ORDER_CLASS_BALANCED_32_11, 2, 3);
+ T(LIBFONTS_SUBPIXEL_ORDER_CLASS_BALANCED_13_12, 3, 2);
+ ASSERT(errno == EDOM);
+
return 0;
}