diff options
author | George Kadianakis <desnacked@riseup.net> | 2018-11-01 12:55:04 +0200 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2018-11-01 12:55:04 +0200 |
commit | da716fdfbb08952b971882eba1dabca2fef9c7f3 (patch) | |
tree | e93d84d3e1a50a48efe37ba5d43591bac85fafe7 /src/test | |
parent | f874ab26401ca269074963697ddcad879b3b4e3a (diff) | |
download | tor-da716fdfbb08952b971882eba1dabca2fef9c7f3.tar.gz tor-da716fdfbb08952b971882eba1dabca2fef9c7f3.zip |
Add tests for the string_is_utf8_no_bom() function.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_util.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index 7bc1b7921a..0678251137 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -4024,6 +4024,13 @@ test_util_string_is_utf8(void *ptr) tt_int_op(1, OP_EQ, string_is_utf8("ascii\x7f\n", 7)); tt_int_op(1, OP_EQ, string_is_utf8("Risqu\u00e9=1", 9)); + /* Test the utf8_no_bom function */ + tt_int_op(0, OP_EQ, string_is_utf8_no_bom("\uFEFF", 3)); + tt_int_op(0, OP_EQ, string_is_utf8_no_bom("\uFFFE", 3)); + tt_int_op(0, OP_EQ, string_is_utf8_no_bom("\uFEFFlove", 7)); + tt_int_op(1, OP_EQ, string_is_utf8_no_bom("loveandrespect", + strlen("loveandrespect"))); + // Validate exactly 'len' bytes. tt_int_op(0, OP_EQ, string_is_utf8("\0\x80", 2)); tt_int_op(0, OP_EQ, string_is_utf8("Risqu\u00e9=1", 6)); |