[ion/tests] More UTF8Decoder tests

This commit is contained in:
Léa Saviot
2019-01-23 11:31:00 +01:00
committed by Émilie Feral
parent 7df8c975c8
commit 9184ade87b

View File

@@ -7,9 +7,21 @@ void assert_decodes_to(const char * string, CodePoint c) {
quiz_assert(d.nextCodePoint() == 0);
}
QUIZ_CASE(ion_utf8_decoder) {
void assert_previous_code_point_is_to(const char * string, const char * stringPosition, CodePoint c) {
UTF8Decoder d(string, stringPosition);
quiz_assert(d.previousCodePoint() == c);
}
QUIZ_CASE(ion_utf8_decode_forward) {
assert_decodes_to("\x20", 0x20);
assert_decodes_to("\xC2\xA2", 0xA2);
assert_decodes_to("\xED\x9F\xBF", 0xD7FF);
assert_decodes_to("\xCC\x81", 0x301);
}
QUIZ_CASE(ion_utf8_decode_backwards) {
const char * a = "abcde";
assert_previous_code_point_is_to(a, a+1, *a);
assert_previous_code_point_is_to(a, a+4, *(a+3));
assert_previous_code_point_is_to(a, a+6, *(a+5));
}