//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // template // class codecvt_utf16 // : public codecvt // { // // unspecified // }; // int length(stateT& state, const externT* from, const externT* from_end, // size_t max) const; #include #include int main() { { typedef std::codecvt_utf16 C; C c; char n[4] = {0xD8, 0xC0, 0xDC, 0x03}; std::mbstate_t m; int r = c.length(m, n, n+4, 2); assert(r == 4); n[0] = char(0x10); n[1] = char(0x05); r = c.length(m, n, n+2, 2); assert(r == 2); n[0] = char(0x04); n[1] = char(0x53); r = c.length(m, n, n+2, 2); assert(r == 2); n[0] = char(0x00); n[1] = char(0x56); r = c.length(m, n, n+2, 2); assert(r == 2); } { typedef std::codecvt_utf16 C; C c; char n[4] = {0xD8, 0xC0, 0xDC, 0x03}; std::mbstate_t m; int r = c.length(m, n, n+4, 2); assert(r == 0); n[0] = char(0x10); n[1] = char(0x05); r = c.length(m, n, n+2, 2); assert(r == 0); n[0] = char(0x04); n[1] = char(0x53); r = c.length(m, n, n+2, 2); assert(r == 2); n[0] = char(0x00); n[1] = char(0x56); r = c.length(m, n, n+2, 2); assert(r == 2); } { typedef std::codecvt_utf16 C; C c; char n[6] = {0xFE, 0xFF, 0xD8, 0xC0, 0xDC, 0x03}; std::mbstate_t m; int r = c.length(m, n, n+6, 2); assert(r == 6); n[0] = char(0x10); n[1] = char(0x05); r = c.length(m, n, n+2, 2); assert(r == 2); n[0] = char(0x04); n[1] = char(0x53); r = c.length(m, n, n+2, 2); assert(r == 2); n[0] = char(0x00); n[1] = char(0x56); r = c.length(m, n, n+2, 2); assert(r == 2); } { typedef std::codecvt_utf16 C; C c; char n[4] = {0xC0, 0xD8, 0x03, 0xDC}; std::mbstate_t m; int r = c.length(m, n, n+4, 2); assert(r == 4); n[1] = char(0x10); n[0] = char(0x05); r = c.length(m, n, n+2, 2); assert(r == 2); n[1] = char(0x04); n[0] = char(0x53); r = c.length(m, n, n+2, 2); assert(r == 2); n[1] = char(0x00); n[0] = char(0x56); r = c.length(m, n, n+2, 2); assert(r == 2); } { typedef std::codecvt_utf16 C; C c; char n[4] = {0xC0, 0xD8, 0x03, 0xDC}; std::mbstate_t m; int r = c.length(m, n, n+4, 2); assert(r == 0); n[1] = char(0x10); n[0] = char(0x05); r = c.length(m, n, n+2, 2); assert(r == 0); n[1] = char(0x04); n[0] = char(0x53); r = c.length(m, n, n+2, 2); assert(r == 2); n[1] = char(0x00); n[0] = char(0x56); r = c.length(m, n, n+2, 2); assert(r == 2); } { typedef std::codecvt_utf16 C; C c; char n[6] = {0xFF, 0xFE, 0xC0, 0xD8, 0x03, 0xDC}; std::mbstate_t m; int r = c.length(m, n, n+6, 2); assert(r == 6); n[1] = char(0x10); n[0] = char(0x05); r = c.length(m, n, n+2, 2); assert(r == 2); n[1] = char(0x04); n[0] = char(0x53); r = c.length(m, n, n+2, 2); assert(r == 2); n[1] = char(0x00); n[0] = char(0x56); r = c.length(m, n, n+2, 2); assert(r == 2); } { typedef std::codecvt_utf16 C; C c; char n[4] = {0xD8, 0xC0, 0xDC, 0x03}; std::mbstate_t m; int r = c.length(m, n, n+4, 2); assert(r == 4); n[0] = char(0x10); n[1] = char(0x05); r = c.length(m, n, n+2, 2); assert(r == 2); n[0] = char(0x04); n[1] = char(0x53); r = c.length(m, n, n+2, 2); assert(r == 2); n[0] = char(0x00); n[1] = char(0x56); r = c.length(m, n, n+2, 2); assert(r == 2); } { typedef std::codecvt_utf16 C; C c; char n[4] = {0xD8, 0xC0, 0xDC, 0x03}; std::mbstate_t m; int r = c.length(m, n, n+4, 2); assert(r == 0); n[0] = char(0x10); n[1] = char(0x05); r = c.length(m, n, n+2, 2); assert(r == 0); n[0] = char(0x04); n[1] = char(0x53); r = c.length(m, n, n+2, 2); assert(r == 2); n[0] = char(0x00); n[1] = char(0x56); r = c.length(m, n, n+2, 2); assert(r == 2); } { typedef std::codecvt_utf16 C; C c; char n[6] = {0xFE, 0xFF, 0xD8, 0xC0, 0xDC, 0x03}; std::mbstate_t m; int r = c.length(m, n, n+6, 2); assert(r == 6); n[0] = char(0x10); n[1] = char(0x05); r = c.length(m, n, n+2, 2); assert(r == 2); n[0] = char(0x04); n[1] = char(0x53); r = c.length(m, n, n+2, 2); assert(r == 2); n[0] = char(0x00); n[1] = char(0x56); r = c.length(m, n, n+2, 2); assert(r == 2); } { typedef std::codecvt_utf16 C; C c; char n[4] = {0xC0, 0xD8, 0x03, 0xDC}; std::mbstate_t m; int r = c.length(m, n, n+4, 2); assert(r == 4); n[1] = char(0x10); n[0] = char(0x05); r = c.length(m, n, n+2, 2); assert(r == 2); n[1] = char(0x04); n[0] = char(0x53); r = c.length(m, n, n+2, 2); assert(r == 2); n[1] = char(0x00); n[0] = char(0x56); r = c.length(m, n, n+2, 2); assert(r == 2); } { typedef std::codecvt_utf16 C; C c; char n[4] = {0xC0, 0xD8, 0x03, 0xDC}; std::mbstate_t m; int r = c.length(m, n, n+4, 2); assert(r == 0); n[1] = char(0x10); n[0] = char(0x05); r = c.length(m, n, n+2, 2); assert(r == 0); n[1] = char(0x04); n[0] = char(0x53); r = c.length(m, n, n+2, 2); assert(r == 2); n[1] = char(0x00); n[0] = char(0x56); r = c.length(m, n, n+2, 2); assert(r == 2); } { typedef std::codecvt_utf16 C; C c; char n[6] = {0xFF, 0xFE, 0xC0, 0xD8, 0x03, 0xDC}; std::mbstate_t m; int r = c.length(m, n, n+6, 2); assert(r == 6); n[1] = char(0x10); n[0] = char(0x05); r = c.length(m, n, n+2, 2); assert(r == 2); n[1] = char(0x04); n[0] = char(0x53); r = c.length(m, n, n+2, 2); assert(r == 2); n[1] = char(0x00); n[0] = char(0x56); r = c.length(m, n, n+2, 2); assert(r == 2); } { typedef std::codecvt_utf16 C; C c; char n[4] = {0xD8, 0xC0, 0xDC, 0x03}; std::mbstate_t m; int r = c.length(m, n, n+4, 2); assert(r == 0); n[0] = char(0x10); n[1] = char(0x05); r = c.length(m, n, n+2, 2); assert(r == 2); n[0] = char(0x04); n[1] = char(0x53); r = c.length(m, n, n+2, 2); assert(r == 2); n[0] = char(0x00); n[1] = char(0x56); r = c.length(m, n, n+2, 2); assert(r == 2); } { typedef std::codecvt_utf16 C; C c; char n[4] = {0xD8, 0xC0, 0xDC, 0x03}; std::mbstate_t m; int r = c.length(m, n, n+4, 2); assert(r == 0); n[0] = char(0x10); n[1] = char(0x05); r = c.length(m, n, n+2, 2); assert(r == 0); n[0] = char(0x04); n[1] = char(0x53); r = c.length(m, n, n+2, 2); assert(r == 2); n[0] = char(0x00); n[1] = char(0x56); r = c.length(m, n, n+2, 2); assert(r == 2); } { typedef std::codecvt_utf16 C; C c; char n[6] = {0xFE, 0xFF, 0xD8, 0xC0, 0xDC, 0x03}; std::mbstate_t m; int r = c.length(m, n, n+6, 2); assert(r == 2); n[0] = char(0x10); n[1] = char(0x05); r = c.length(m, n, n+2, 2); assert(r == 2); n[0] = char(0x04); n[1] = char(0x53); r = c.length(m, n, n+2, 2); assert(r == 2); n[0] = char(0x00); n[1] = char(0x56); r = c.length(m, n, n+2, 2); assert(r == 2); } { typedef std::codecvt_utf16 C; C c; char n[4] = {0xC0, 0xD8, 0x03, 0xDC}; std::mbstate_t m; int r = c.length(m, n, n+4, 2); assert(r == 0); n[1] = char(0x10); n[0] = char(0x05); r = c.length(m, n, n+2, 2); assert(r == 2); n[1] = char(0x04); n[0] = char(0x53); r = c.length(m, n, n+2, 2); assert(r == 2); n[1] = char(0x00); n[0] = char(0x56); r = c.length(m, n, n+2, 2); assert(r == 2); } { typedef std::codecvt_utf16 C; C c; char n[4] = {0xC0, 0xD8, 0x03, 0xDC}; std::mbstate_t m; int r = c.length(m, n, n+4, 2); assert(r == 0); n[1] = char(0x10); n[0] = char(0x05); r = c.length(m, n, n+2, 2); assert(r == 0); n[1] = char(0x04); n[0] = char(0x53); r = c.length(m, n, n+2, 2); assert(r == 2); n[1] = char(0x00); n[0] = char(0x56); r = c.length(m, n, n+2, 2); assert(r == 2); } { typedef std::codecvt_utf16 C; C c; char n[6] = {0xFF, 0xFE, 0xC0, 0xD8, 0x03, 0xDC}; std::mbstate_t m; int r = c.length(m, n, n+6, 2); assert(r == 2); n[1] = char(0x10); n[0] = char(0x05); r = c.length(m, n, n+2, 2); assert(r == 2); n[1] = char(0x04); n[0] = char(0x53); r = c.length(m, n, n+2, 2); assert(r == 2); n[1] = char(0x00); n[0] = char(0x56); r = c.length(m, n, n+2, 2); assert(r == 2); } }