1 3448adb0 2022-11-02 op /* See LICENSE file for copyright and license details. */
2 3448adb0 2022-11-02 op #include <stdbool.h>
3 3448adb0 2022-11-02 op #include <stdint.h>
5 3448adb0 2022-11-02 op #include "../gen/sentence-test.h"
6 3448adb0 2022-11-02 op #include "../grapheme.h"
7 3448adb0 2022-11-02 op #include "util.h"
9 3448adb0 2022-11-02 op static const struct unit_test_next_break next_sentence_break[] = {
11 3448adb0 2022-11-02 op .description = "NULL input",
16 3448adb0 2022-11-02 op .output = { 0 },
19 3448adb0 2022-11-02 op .description = "empty input",
21 3448adb0 2022-11-02 op .src = (uint_least32_t *)(uint_least32_t[]){ 0x0 },
24 3448adb0 2022-11-02 op .output = { 0 },
27 3448adb0 2022-11-02 op .description = "empty input, null-terminated",
29 3448adb0 2022-11-02 op .src = (uint_least32_t *)(uint_least32_t[]){ 0x0 },
30 3448adb0 2022-11-02 op .srclen = SIZE_MAX,
32 3448adb0 2022-11-02 op .output = { 0 },
35 3448adb0 2022-11-02 op .description = "one sentence",
37 3448adb0 2022-11-02 op .src = (uint_least32_t *)(uint_least32_t[]){ 0x1F1E9, 0x1F1EA, 0x2E, 0x20, 0x2A },
40 3448adb0 2022-11-02 op .output = { 4 },
43 3448adb0 2022-11-02 op .description = "one sentence, null-terminated",
45 3448adb0 2022-11-02 op .src = (uint_least32_t *)(uint_least32_t[]){ 0x1F1E9, 0x1F1EA, 0x2E, 0x20, 0x2A, 0x0 },
46 3448adb0 2022-11-02 op .srclen = SIZE_MAX,
48 3448adb0 2022-11-02 op .output = { 4 },
52 3448adb0 2022-11-02 op static const struct unit_test_next_break_utf8 next_sentence_break_utf8[] = {
54 3448adb0 2022-11-02 op .description = "NULL input",
59 3448adb0 2022-11-02 op .output = { 0 },
62 3448adb0 2022-11-02 op .description = "empty input",
63 3448adb0 2022-11-02 op .input = { "", 0 },
64 3448adb0 2022-11-02 op .output = { 0 },
67 3448adb0 2022-11-02 op .description = "empty input, NUL-terminated",
68 3448adb0 2022-11-02 op .input = { "", SIZE_MAX },
69 3448adb0 2022-11-02 op .output = { 0 },
72 3448adb0 2022-11-02 op .description = "one sentence",
73 3448adb0 2022-11-02 op .input = { "\xF0\x9F\x87\xA9\xF0\x9F\x87\xAA is the flag of Germany. It", 36 },
74 3448adb0 2022-11-02 op .output = { 34 },
77 3448adb0 2022-11-02 op .description = "one sentence, fragment",
78 3448adb0 2022-11-02 op .input = { "\xF0\x9F\x87\xA9\xF0", 5 },
79 3448adb0 2022-11-02 op .output = { 4 },
82 3448adb0 2022-11-02 op .description = "one sentence, NUL-terminated",
83 3448adb0 2022-11-02 op .input = { "\xF0\x9F\x87\xA9\xF0\x9F\x87\xAA is the flag of Germany. It", SIZE_MAX },
84 3448adb0 2022-11-02 op .output = { 34 },
87 3448adb0 2022-11-02 op .description = "one sentence, fragment, NUL-terminated",
88 3448adb0 2022-11-02 op .input = { "\xF0\x9F\x87\xA9\xF0\x9F", SIZE_MAX },
89 3448adb0 2022-11-02 op .output = { 6 },
94 3448adb0 2022-11-02 op unit_test_callback_next_sentence_break(const void *t, size_t off,
95 3448adb0 2022-11-02 op const char *name,
96 3448adb0 2022-11-02 op const char *argv0)
98 3448adb0 2022-11-02 op return unit_test_callback_next_break(t, off,
99 3448adb0 2022-11-02 op grapheme_next_sentence_break,
100 3448adb0 2022-11-02 op name, argv0);
104 3448adb0 2022-11-02 op unit_test_callback_next_sentence_break_utf8(const void *t, size_t off,
105 3448adb0 2022-11-02 op const char *name,
106 3448adb0 2022-11-02 op const char *argv0)
108 3448adb0 2022-11-02 op return unit_test_callback_next_break_utf8(t, off,
109 3448adb0 2022-11-02 op grapheme_next_sentence_break_utf8,
110 3448adb0 2022-11-02 op name, argv0);
114 3448adb0 2022-11-02 op main(int argc, char *argv[])
118 3448adb0 2022-11-02 op return run_break_tests(grapheme_next_sentence_break,
119 3448adb0 2022-11-02 op sentence_break_test,
120 3448adb0 2022-11-02 op LEN(sentence_break_test), argv[0]) +
121 3448adb0 2022-11-02 op run_unit_tests(unit_test_callback_next_sentence_break,
122 3448adb0 2022-11-02 op next_sentence_break, LEN(next_sentence_break),
123 3448adb0 2022-11-02 op "grapheme_next_sentence_break", argv[0]) +
124 3448adb0 2022-11-02 op run_unit_tests(unit_test_callback_next_sentence_break_utf8,
125 3448adb0 2022-11-02 op next_sentence_break_utf8, LEN(next_sentence_break_utf8),
126 3448adb0 2022-11-02 op "grapheme_next_character_break_utf8", argv[0]);