Skip to content

Commit 63f31c9

Browse files
authored
Improve fuzzer code coverage (#239)
* fuzz: test grapheme break functions * fuzz: cover character lumping
1 parent 39dbf50 commit 63f31c9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

test/fuzzer.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
1111
if(data[size-1] != '\0') return 0;
1212

1313
const uint8_t* ptr = data;
14-
utf8proc_int32_t c = 0;
14+
utf8proc_int32_t c = 0, c_prev = 0, state = 0;
1515
utf8proc_option_t options;
1616
utf8proc_ssize_t ret, bytes = 0;
1717
size_t len = strlen((const char*)data);
@@ -34,6 +34,11 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
3434
utf8proc_category(c);
3535
utf8proc_category_string(c);
3636
utf8proc_codepoint_valid(c);
37+
38+
utf8proc_grapheme_break(c_prev, c);
39+
utf8proc_grapheme_break_stateful(c_prev, c, &state);
40+
41+
c_prev = c;
3742
}
3843

3944
utf8proc_int32_t *copy = size >= 4 ? NULL : malloc(size);
@@ -58,6 +63,10 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
5863
memcpy(copy, data, size);
5964
utf8proc_normalize_utf32(copy, size, options);
6065

66+
options = UTF8PROC_LUMP;
67+
memcpy(copy, data, size);
68+
utf8proc_normalize_utf32(copy, size, options);
69+
6170
options = 0;
6271
memcpy(copy, data, size);
6372
utf8proc_normalize_utf32(copy, size, options);

0 commit comments

Comments
 (0)