diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-04-23 22:39:27 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-04-24 00:25:43 +0200 |
commit | 22b35c49289157204b35a851f3cb9cade9e98559 (patch) | |
tree | 49b9f289b1feccaefe04355dd80c5e7c10917cbc /libtests | |
parent | 5bbb0d4c307bff58e9928a1c757438d033687ce3 (diff) | |
download | qpdf-22b35c49289157204b35a851f3cb9cade9e98559.tar.zst |
Expose QUtil::get_next_utf8_codepoint
Diffstat (limited to 'libtests')
-rw-r--r-- | libtests/qutil.cc | 27 |
1 files changed, 27 insertions, 0 deletions
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 |