blob: 41fcd208032296f36765f6d087b5925e38690c47 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#define BOOST_TEST_MODULE unicode_test
#include <boost/test/included/unit_test.hpp>
#include <string>
#include <unicode.h>
BOOST_AUTO_TEST_CASE(utf8_to_utf16)
{
std::u8string u8{u8"ascii string1"};
std::u16string u16{unicode::utf8_to_utf16(u8)};
BOOST_CHECK(u16 == u"ascii string1");
}
// TODO:
// invalid bytes
// an unexpected continuation byte
// a non-continuation byte before the end of the character
// the string ending before the end of the character (which can happen in simple string truncation)
// an overlong encoding
// a sequence that decodes to an invalid code point
//
// high and low surrogate halves used by UTF-16 (U+D800 through U+DFFF) and code points not encodable by UTF-16 (those after U+10FFFF)
|