Blob


1 /* See LICENSE file for copyright and license details. */
2 #ifndef UTIL_H
3 #define UTIL_H
5 #include "../gen/types.h"
6 #include "../grapheme.h"
8 #undef MIN
9 #define MIN(x,y) ((x) < (y) ? (x) : (y))
10 #undef LEN
11 #define LEN(x) (sizeof(x) / sizeof(*(x)))
13 struct unit_test_next_break {
14 const char *description;
15 struct {
16 const uint_least32_t *src;
17 size_t srclen;
18 } input;
19 struct {
20 size_t ret;
21 } output;
22 };
24 struct unit_test_next_break_utf8 {
25 const char *description;
26 struct {
27 const char *src;
28 size_t srclen;
29 } input;
30 struct {
31 size_t ret;
32 } output;
33 };
35 int run_break_tests(size_t (*next_break)(const uint_least32_t *, size_t),
36 const struct break_test *test, size_t testlen,
37 const char *);
38 int run_unit_tests(int (*unit_test_callback)(const void *, size_t, const char *,
39 const char *), const void *, size_t, const char *, const char *);
41 int unit_test_callback_next_break(const struct unit_test_next_break *, size_t,
42 size_t (*next_break)(const uint_least32_t *, size_t),
43 const char *, const char *);
44 int unit_test_callback_next_break_utf8(const struct unit_test_next_break_utf8 *,
45 size_t,
46 size_t (*next_break_utf8)(const char *, size_t),
47 const char *, const char *);
49 #endif /* UTIL_H */