aboutsummaryrefslogtreecommitdiffstats
path: root/libfonts_parse_aa__.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-01-08 22:39:00 +0100
committerMattias Andrée <maandree@kth.se>2023-01-08 22:39:00 +0100
commit68d533e7fdbbd33d720412aaab1848200b6c8863 (patch)
treee6310d970993ccb4886d6e6a4e2924cce0f14d89 /libfonts_parse_aa__.c
parentFix warnings (diff)
downloadlibfonts-68d533e7fdbbd33d720412aaab1848200b6c8863.tar.gz
libfonts-68d533e7fdbbd33d720412aaab1848200b6c8863.tar.bz2
libfonts-68d533e7fdbbd33d720412aaab1848200b6c8863.tar.xz
m + add tests
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libfonts_parse_aa__.c')
-rw-r--r--libfonts_parse_aa__.c46
1 files changed, 25 insertions, 21 deletions
diff --git a/libfonts_parse_aa__.c b/libfonts_parse_aa__.c
index 5946b1c..0ed9a3d 100644
--- a/libfonts_parse_aa__.c
+++ b/libfonts_parse_aa__.c
@@ -3,25 +3,6 @@
#ifndef TEST
-#define LIST_ANTIALIASINGS(X)\
- X(LIBFONTS_ANTIALIASING_UNSPECIFIED, "unspecified")\
- X(LIBFONTS_ANTIALIASING_NONE, "none")\
- X(LIBFONTS_ANTIALIASING_NONE, "aliased")\
- X(LIBFONTS_ANTIALIASING_GREYSCALE, "greyscale")\
- X(LIBFONTS_ANTIALIASING_GREYSCALE, "grayscale")\
- X(LIBFONTS_ANTIALIASING_GREYSCALE, "grey")\
- X(LIBFONTS_ANTIALIASING_GREYSCALE, "gray")\
- X(LIBFONTS_ANTIALIASING_GREYSCALE, "antialiased")\
- X(LIBFONTS_ANTIALIASING_GREYSCALE_FORCED, "greyscale!")\
- X(LIBFONTS_ANTIALIASING_GREYSCALE_FORCED, "grayscale!")\
- X(LIBFONTS_ANTIALIASING_GREYSCALE_FORCED, "grey!")\
- X(LIBFONTS_ANTIALIASING_GREYSCALE_FORCED, "gray!")\
- X(LIBFONTS_ANTIALIASING_GREYSCALE_FORCED, "antialiased!")\
- X(LIBFONTS_ANTIALIASING_SUBPIXEL, "subpixel")\
- X(LIBFONTS_ANTIALIASING_SUBPIXEL, "glitter")\
- X(LIBFONTS_ANTIALIASING_SUBPIXEL_FORCED, "subpixel!")\
- X(LIBFONTS_ANTIALIASING_SUBPIXEL_FORCED, "glitter!")
-
int
libfonts_parse_aa__(enum libfonts_antialiasing *outp, const char *value)
{
@@ -29,7 +10,7 @@ libfonts_parse_aa__(enum libfonts_antialiasing *outp, const char *value)
if (!strcasecmp(value, S)) {\
*outp = C;\
} else
- LIST_ANTIALIASINGS(X) {
+ LIST_ANTIALIASINGS(X,) {
return 0;
}
#undef X
@@ -44,7 +25,30 @@ libfonts_parse_aa__(enum libfonts_antialiasing *outp, const char *value)
int
main(void)
{
- return 0; /* TODO add test */
+ enum libfonts_antialiasing res;
+ char buf[1024];
+ size_t i;
+
+#define X(C, S)\
+ do {\
+ res = 999;\
+ ASSERT(libfonts_parse_aa__(&res, S) == 1);\
+ ASSERT(res == C);\
+ strcpy(buf, S);\
+ for (i = 0; buf[i]; i++)\
+ buf[i] = toupper(buf[i]);\
+ res = 999;\
+ ASSERT(libfonts_parse_aa__(&res, buf) == 1);\
+ ASSERT(res == C);\
+ } while (0)
+ LIST_ANTIALIASINGS(X, ;);
+#undef X
+
+ res = 999;
+ ASSERT(libfonts_parse_aa__(&res, " something else ") == 0);
+ ASSERT(res == 999);
+
+ return 0;
}