From 22b35c49289157204b35a851f3cb9cade9e98559 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 23 Apr 2022 16:39:27 -0400 Subject: Expose QUtil::get_next_utf8_codepoint --- libtests/qutil.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'libtests/qutil.cc') diff --git a/libtests/qutil.cc b/libtests/qutil.cc index 324dd84e..eb16bf0b 100644 --- a/libtests/qutil.cc +++ b/libtests/qutil.cc @@ -240,6 +240,33 @@ print_utf8(unsigned long val) } } std::cout << std::endl; + + // Boundary conditions for QUtil::get_next_utf8_codepoint, which is + // also tested indirectly through test_pdf_unicode.cc. + std::string utf8 = "\xcf\x80\xcf\x30\xEF\xBF\x30\x31\xcf"; + size_t pos = 0; + bool error = false; + assert(QUtil::get_next_utf8_codepoint(utf8, pos, error) == 0x3c0); + assert(pos == 2); + assert(!error); + assert(QUtil::get_next_utf8_codepoint(utf8, pos, error) == 0xfffd); + assert(pos == 3); + assert(error); + assert(QUtil::get_next_utf8_codepoint(utf8, pos, error) == 0x30); + assert(pos == 4); + assert(!error); + assert(QUtil::get_next_utf8_codepoint(utf8, pos, error) == 0xfffd); + assert(pos == 6); + assert(error); + assert(QUtil::get_next_utf8_codepoint(utf8, pos, error) == 0x30); + assert(pos == 7); + assert(!error); + assert(QUtil::get_next_utf8_codepoint(utf8, pos, error) == 0x31); + assert(pos == 8); + assert(!error); + assert(QUtil::get_next_utf8_codepoint(utf8, pos, error) == 0xfffd); + assert(pos == 9); + assert(error); } void -- cgit v1.2.3-54-g00ecf