|
|
|
@ -1,19 +1,19 @@
|
|
|
|
|
/*
|
|
|
|
|
/*
|
|
|
|
|
Unix SMB/CIFS implementation.
|
|
|
|
|
test suite for the charcnv functions
|
|
|
|
|
|
|
|
|
|
Copyright (C) Andrew Bartlett 2011
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
@ -34,7 +34,7 @@ struct torture_suite *torture_local_string_case(TALLOC_CTX *mem_ctx);
|
|
|
|
|
* http://en.wikipedia.org/w/index.php?title=Ancient_Greek&oldid=421361065#Example_text
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
const char *plato_english_ascii =
|
|
|
|
|
const char *plato_english_ascii =
|
|
|
|
|
"What you, men of Athens, have learned from my accusers, I do not"
|
|
|
|
|
" know: but I, for my part, nearly forgot who I was thanks to them since"
|
|
|
|
|
" they spoke so persuasively. And yet, of the truth, they have spoken,"
|
|
|
|
@ -51,7 +51,7 @@ const char *plato_english_utf16le_base64 =
|
|
|
|
|
"AGsAZQBuACwAIABvAG4AZQAgAG0AaQBnAGgAdAAgAHMAYQB5ACwAIABuAG8AdABoAGkAbgBnACAA"
|
|
|
|
|
"YQB0ACAAYQBsAGwALgA=";
|
|
|
|
|
|
|
|
|
|
static const char *plato_utf8_base64 =
|
|
|
|
|
static const char *plato_utf8_base64 =
|
|
|
|
|
"4b2Nz4TOuSDOvOG9ss69IOG9kc68zrXhv5bPgiwg4b2mIOG8hM69zrTPgc61z4IgzobOuM63zr3O"
|
|
|
|
|
"seG/ls6/zrksIM+AzrXPgM+Mzr3OuM6xz4TOtSDhvZHPgOG9uCDPhOG/ts69IOG8kM684b+2zr0g"
|
|
|
|
|
"zrrOsc+EzrfOs8+Mz4HPic69LCDOv+G9kM66IM6/4by2zrTOsTog4byQzrPhvbwgzrQnIM6/4b2W"
|
|
|
|
@ -61,7 +61,7 @@ static const char *plato_utf8_base64 =
|
|
|
|
|
"4b2hz4Ig4byUz4DOv8+CIM614bywz4DOteG/ls69IM6/4b2QzrThvbLOvSDOteG8sM+Bzq7Ous6x"
|
|
|
|
|
"z4POuc69Lg==";
|
|
|
|
|
|
|
|
|
|
static const char *plato_utf16le_base64 =
|
|
|
|
|
static const char *plato_utf16le_base64 =
|
|
|
|
|
"TR/EA7kDIAC8A3IfvQMgAFEfvAO1A9YfwgMsACAAZh8gAAQfvQO0A8EDtQPCAyAAhgO4A7cDvQOx"
|
|
|
|
|
"A9YfvwO5AywAIADAA7UDwAPMA70DuAOxA8QDtQMgAFEfwAN4HyAAxAP2H70DIAAQH7wD9h+9AyAA"
|
|
|
|
|
"ugOxA8QDtwOzA8wDwQPJA70DLAAgAL8DUB+6AyAAvwM2H7QDsQM6ACAAEB+zA3wfIAC0AycAIAC/"
|
|
|
|
@ -71,14 +71,14 @@ static const char *plato_utf16le_base64 =
|
|
|
|
|
"swO1AyAAYR/CAyAAFB/AA78DwgMgALUDMB/AA7UD1h+9AyAAvwNQH7QDch+9AyAAtQMwH8EDrgO6"
|
|
|
|
|
"A7EDwwO5A70DLgA=";
|
|
|
|
|
|
|
|
|
|
static const char *plato_latin_utf8_base64 =
|
|
|
|
|
static const char *plato_latin_utf8_base64 =
|
|
|
|
|
"SMOzdGkgbcOobiBodW1lw65zLCDDtCDDoW5kcmVzIEF0aMSTbmHDrm9pLCBwZXDDs250aGF0ZSBo"
|
|
|
|
|
"dXDDsiB0w7RuIGVtw7RuIGthdMSTZ8OzcsWNbiwgb3VrIG/DrmRhOiBlZ+G5kSBkJyBvw7tuIGth"
|
|
|
|
|
"w6wgYXV0w7JzIGh1cCcgYXV0xY1uIG9sw61nb3UgZW1hdXRvw7sgZXBlbGF0aMOzbcSTbiwgaG/D"
|
|
|
|
|
"unTFjSBwaXRoYW7DtHMgw6lsZWdvbi4gS2HDrXRvaSBhbMSTdGjDqXMgZ2UgaMWNcyDDqXBvcyBl"
|
|
|
|
|
"aXBlw65uIG91ZMOobiBlaXLhuJdrYXNpbi4=";
|
|
|
|
|
|
|
|
|
|
static const char *plato_latin_utf16le_base64 =
|
|
|
|
|
static const char *plato_latin_utf16le_base64 =
|
|
|
|
|
"SADzAHQAaQAgAG0A6ABuACAAaAB1AG0AZQDuAHMALAAgAPQAIADhAG4AZAByAGUAcwAgAEEAdABo"
|
|
|
|
|
"ABMBbgBhAO4AbwBpACwAIABwAGUAcADzAG4AdABoAGEAdABlACAAaAB1AHAA8gAgAHQA9ABuACAA"
|
|
|
|
|
"ZQBtAPQAbgAgAGsAYQB0ABMBZwDzAHIATQFuACwAIABvAHUAawAgAG8A7gBkAGEAOgAgAGUAZwBR"
|
|
|
|
@ -161,7 +161,7 @@ static bool test_gd_iso8859_cp850_handle(struct torture_context *tctx)
|
|
|
|
|
DATA_BLOB gd_utf16le = base64_decode_data_blob(gd_utf16le_base64);
|
|
|
|
|
DATA_BLOB gd_output;
|
|
|
|
|
DATA_BLOB gd_output2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
talloc_steal(tctx, gd_utf8.data);
|
|
|
|
|
talloc_steal(tctx, gd_cp850.data);
|
|
|
|
|
talloc_steal(tctx, gd_iso8859_1.data);
|
|
|
|
@ -170,14 +170,14 @@ static bool test_gd_iso8859_cp850_handle(struct torture_context *tctx)
|
|
|
|
|
iconv_handle = get_iconv_testing_handle(tctx, "ISO-8859-1", "CP850",
|
|
|
|
|
lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true));
|
|
|
|
|
torture_assert(tctx, iconv_handle, "getting iconv handle");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_DOS,
|
|
|
|
|
gd_utf8.data, gd_utf8.length,
|
|
|
|
|
(void *)&gd_output.data, &gd_output.length),
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_DOS,
|
|
|
|
|
gd_utf8.data, gd_utf8.length,
|
|
|
|
|
(void *)&gd_output.data, &gd_output.length),
|
|
|
|
|
"conversion from UTF8 to (dos charset) ISO-8859-1");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, gd_output, gd_iso8859_1, "conversion from UTF8 to (dos charset) ISO-8859-1 incorrect");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_error_handle(iconv_handle,
|
|
|
|
|
CH_UTF8, CH_DOS,
|
|
|
|
|
gd_utf8.data, gd_utf8.length,
|
|
|
|
@ -254,73 +254,73 @@ static bool test_gd_iso8859_cp850_handle(struct torture_context *tctx)
|
|
|
|
|
torture_assert_errno_equal(tctx, EINVAL, "conversion from short UTF16 to UTF8 should fail EINVAL");
|
|
|
|
|
torture_assert_int_equal(tctx, gd_output.length, 1, "Should only get 1 char of output");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_UNIX,
|
|
|
|
|
gd_utf8.data, gd_utf8.length,
|
|
|
|
|
(void *)&gd_output.data, &gd_output.length),
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_UNIX,
|
|
|
|
|
gd_utf8.data, gd_utf8.length,
|
|
|
|
|
(void *)&gd_output.data, &gd_output.length),
|
|
|
|
|
"conversion from UTF8 to (unix charset) CP850");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, gd_output, gd_cp850, "conversion from UTF8 to (unix charset) CP850 incorrect");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_UTF8,
|
|
|
|
|
gd_utf8.data, gd_utf8.length,
|
|
|
|
|
(void *)&gd_output.data, &gd_output.length),
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_UTF8,
|
|
|
|
|
gd_utf8.data, gd_utf8.length,
|
|
|
|
|
(void *)&gd_output.data, &gd_output.length),
|
|
|
|
|
"conversion from UTF8 to UTF8");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, gd_output, gd_utf8, "conversion from UTF8 to UTF8 incorrect");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF16LE, CH_DOS,
|
|
|
|
|
gd_utf16le.data, gd_utf16le.length,
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF16LE, CH_DOS,
|
|
|
|
|
gd_utf16le.data, gd_utf16le.length,
|
|
|
|
|
(void *)&gd_output.data, &gd_output.length),
|
|
|
|
|
"conversion from UTF16LE to (dos charset) ISO-8859-1");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, gd_output, gd_iso8859_1, "conversion from UTF16LE to (dos charset) ISO-8859-1 incorrect");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_DOS, CH_UTF16LE,
|
|
|
|
|
gd_output.data, gd_output.length,
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_DOS, CH_UTF16LE,
|
|
|
|
|
gd_output.data, gd_output.length,
|
|
|
|
|
(void *)&gd_output2.data, &gd_output2.length),
|
|
|
|
|
"round trip conversion from (dos charset) ISO-8859-1 back to UTF16LE");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, gd_output2, gd_utf16le, "round trip conversion from (dos charset) ISO-8859-1 back to UTF16LE");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF16LE, CH_UNIX,
|
|
|
|
|
gd_utf16le.data, gd_utf16le.length,
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF16LE, CH_UNIX,
|
|
|
|
|
gd_utf16le.data, gd_utf16le.length,
|
|
|
|
|
(void *)&gd_output.data, &gd_output.length),
|
|
|
|
|
"conversion from UTF16LE to (unix charset) CP850");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, gd_output, gd_cp850, "conversion from UTF16LE to (unix charset) CP850 incorrect");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF16LE, CH_UTF8,
|
|
|
|
|
gd_utf16le.data, gd_utf16le.length,
|
|
|
|
|
(void *)&gd_output.data, &gd_output.length),
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF16LE, CH_UTF8,
|
|
|
|
|
gd_utf16le.data, gd_utf16le.length,
|
|
|
|
|
(void *)&gd_output.data, &gd_output.length),
|
|
|
|
|
"conversion from UTF16LE to UTF8");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, gd_output, gd_utf8, "conversion from UTF16LE to UTF8 incorrect");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_DOS, CH_DOS,
|
|
|
|
|
gd_iso8859_1.data, gd_iso8859_1.length,
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_DOS, CH_DOS,
|
|
|
|
|
gd_iso8859_1.data, gd_iso8859_1.length,
|
|
|
|
|
(void *)&gd_output.data, &gd_output.length),
|
|
|
|
|
"conversion from (dos charset) ISO-8859-1 to (dos charset) ISO-8859-1");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, gd_output, gd_iso8859_1, "conversion from UTF16LE to (dos charset) ISO-8859-1 incorrect");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_DOS, CH_UNIX,
|
|
|
|
|
gd_iso8859_1.data, gd_iso8859_1.length,
|
|
|
|
|
(void *)&gd_output.data, &gd_output.length),
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_DOS, CH_UNIX,
|
|
|
|
|
gd_iso8859_1.data, gd_iso8859_1.length,
|
|
|
|
|
(void *)&gd_output.data, &gd_output.length),
|
|
|
|
|
"conversion from (dos charset) ISO-8859-1 to (unix charset) CP850");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, gd_output, gd_cp850, "conversion from UTF16LE to (unix charset) CP850 incorrect");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_DOS, CH_UTF8,
|
|
|
|
|
gd_iso8859_1.data, gd_iso8859_1.length,
|
|
|
|
|
(void *)&gd_output.data, &gd_output.length),
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_DOS, CH_UTF8,
|
|
|
|
|
gd_iso8859_1.data, gd_iso8859_1.length,
|
|
|
|
|
(void *)&gd_output.data, &gd_output.length),
|
|
|
|
|
"conversion from (dos charset) ISO-8859-1 to UTF8");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, gd_output, gd_utf8, "conversion from UTF16LE to UTF8 incorrect");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_DOS, CH_UTF16LE,
|
|
|
|
|
gd_iso8859_1.data, gd_iso8859_1.length,
|
|
|
|
|
(void *)&gd_output.data, &gd_output.length),
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_DOS, CH_UTF16LE,
|
|
|
|
|
gd_iso8859_1.data, gd_iso8859_1.length,
|
|
|
|
|
(void *)&gd_output.data, &gd_output.length),
|
|
|
|
|
"conversion from (dos charset) ISO-8859-1 to UTF16LE");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, gd_output, gd_utf16le, "conversion from (dos charset) ISO-8859-1 to UTF16LE");
|
|
|
|
|
torture_assert_int_equal(tctx,
|
|
|
|
@ -355,12 +355,12 @@ static bool test_gd_minus_1_handle(struct torture_context *tctx)
|
|
|
|
|
DATA_BLOB gd_utf8_terminated;
|
|
|
|
|
DATA_BLOB gd_cp850_terminated;
|
|
|
|
|
DATA_BLOB gd_utf16le_terminated;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
talloc_steal(tctx, gd_utf8.data);
|
|
|
|
|
talloc_steal(tctx, gd_cp850.data);
|
|
|
|
|
talloc_steal(tctx, gd_utf16le.data);
|
|
|
|
|
|
|
|
|
|
iconv_handle = get_iconv_testing_handle(tctx, "CP850", "CP850",
|
|
|
|
|
iconv_handle = get_iconv_testing_handle(tctx, "CP850", "CP850",
|
|
|
|
|
lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true));
|
|
|
|
|
torture_assert(tctx, iconv_handle, "getting iconv handle");
|
|
|
|
|
|
|
|
|
@ -502,11 +502,11 @@ static bool test_gd_minus_1_handle(struct torture_context *tctx)
|
|
|
|
|
(void *)gd_output.data, gd_output.length, &gd_output.length),
|
|
|
|
|
"conversion from UTF16LE to UTF8 null terminated");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, gd_output, gd_cp850_terminated, "conversion from UTF16LE to UTF8 null terminated early");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Now null terminate the string particularly early, the confirm we don't skip the NULL and convert any further */
|
|
|
|
|
gd_utf8_terminated.data[1] = '\0';
|
|
|
|
|
gd_utf8_terminated.length = 2; /* used for the comparison only */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gd_utf16le_terminated.data[2] = '\0';
|
|
|
|
|
gd_utf16le_terminated.data[3] = '\0';
|
|
|
|
|
gd_utf16le_terminated.length = 4; /* used for the comparison only */
|
|
|
|
@ -545,7 +545,7 @@ static bool test_gd_ascii_handle(struct torture_context *tctx)
|
|
|
|
|
talloc_steal(tctx, gd_iso8859_1.data);
|
|
|
|
|
talloc_steal(tctx, gd_utf16le.data);
|
|
|
|
|
|
|
|
|
|
iconv_handle = get_iconv_testing_handle(tctx, "ASCII", "UTF8",
|
|
|
|
|
iconv_handle = get_iconv_testing_handle(tctx, "ASCII", "UTF8",
|
|
|
|
|
lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true));
|
|
|
|
|
torture_assert(tctx, iconv_handle, "getting iconv handle");
|
|
|
|
|
|
|
|
|
@ -586,7 +586,7 @@ static bool test_gd_ascii_handle(struct torture_context *tctx)
|
|
|
|
|
gd_utf8.data, gd_utf8.length,
|
|
|
|
|
(void *)gd_output.data, gd_output.length,
|
|
|
|
|
&gd_output.length) == false,
|
|
|
|
|
"conversion from UTF8 to (dos charset) ASCII should fail due to too illigal seqence");
|
|
|
|
|
"conversion from UTF8 to (dos charset) ASCII should fail due to illegal sequence");
|
|
|
|
|
torture_assert_errno_equal(tctx, EILSEQ, "conversion from UTF8 to (dos charset) ISO-8859-1 should fail EILSEQ");
|
|
|
|
|
torture_assert_int_equal(tctx, gd_output.length, 1, "Should only get 2 char of output");
|
|
|
|
|
|
|
|
|
@ -612,49 +612,49 @@ static bool test_plato_english_iso8859_cp850_handle(struct torture_context *tctx
|
|
|
|
|
DATA_BLOB plato_english_utf16le = base64_decode_data_blob(plato_english_utf16le_base64);
|
|
|
|
|
DATA_BLOB plato_english_output;
|
|
|
|
|
DATA_BLOB plato_english_output2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
talloc_steal(tctx, plato_english_utf16le.data);
|
|
|
|
|
|
|
|
|
|
iconv_handle = get_iconv_testing_handle(tctx, "ISO-8859-1", "CP850",
|
|
|
|
|
iconv_handle = get_iconv_testing_handle(tctx, "ISO-8859-1", "CP850",
|
|
|
|
|
lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true));
|
|
|
|
|
torture_assert(tctx, iconv_handle, "getting iconv handle");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_DOS,
|
|
|
|
|
plato_english_utf8.data, plato_english_utf8.length,
|
|
|
|
|
(void *)&plato_english_output.data, &plato_english_output.length),
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_DOS,
|
|
|
|
|
plato_english_utf8.data, plato_english_utf8.length,
|
|
|
|
|
(void *)&plato_english_output.data, &plato_english_output.length),
|
|
|
|
|
"conversion from UTF8 to (dos charset) ISO-8859-1");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, plato_english_output, plato_english_iso8859_1, "conversion from UTF8 to (dos charset) ISO-8859-1 incorrect");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_UNIX,
|
|
|
|
|
plato_english_utf8.data, plato_english_utf8.length,
|
|
|
|
|
(void *)&plato_english_output.data, &plato_english_output.length),
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_UNIX,
|
|
|
|
|
plato_english_utf8.data, plato_english_utf8.length,
|
|
|
|
|
(void *)&plato_english_output.data, &plato_english_output.length),
|
|
|
|
|
"conversion from UTF8 to (unix charset) CP850");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, plato_english_output, plato_english_cp850, "conversion from UTF8 to (unix charset) CP850 incorrect");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_UTF8,
|
|
|
|
|
plato_english_utf8.data, plato_english_utf8.length,
|
|
|
|
|
(void *)&plato_english_output.data, &plato_english_output.length),
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_UTF8,
|
|
|
|
|
plato_english_utf8.data, plato_english_utf8.length,
|
|
|
|
|
(void *)&plato_english_output.data, &plato_english_output.length),
|
|
|
|
|
"conversion from UTF8 to UTF8");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, plato_english_output, plato_english_utf8, "conversion from UTF8 to UTF8 incorrect");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF16LE, CH_DOS,
|
|
|
|
|
plato_english_utf16le.data, plato_english_utf16le.length,
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF16LE, CH_DOS,
|
|
|
|
|
plato_english_utf16le.data, plato_english_utf16le.length,
|
|
|
|
|
(void *)&plato_english_output.data, &plato_english_output.length),
|
|
|
|
|
"conversion from UTF16LE to (dos charset) ISO-8859-1");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, plato_english_output, plato_english_iso8859_1, "conversion from UTF16LE to (dos charset) ISO-8859-1 incorrect");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_DOS, CH_UTF16LE,
|
|
|
|
|
plato_english_output.data, plato_english_output.length,
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_DOS, CH_UTF16LE,
|
|
|
|
|
plato_english_output.data, plato_english_output.length,
|
|
|
|
|
(void *)&plato_english_output2.data, &plato_english_output2.length),
|
|
|
|
|
"round trip conversion from (dos charset) ISO-8859-1 back to UTF16LE");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, plato_english_output2, plato_english_utf16le, "round trip conversion from (dos charset) ISO-8859-1 back to UTF16LE");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF16LE, CH_UTF8,
|
|
|
|
|
plato_english_utf16le.data, plato_english_utf16le.length,
|
|
|
|
|
(void *)&plato_english_output.data, &plato_english_output.length),
|
|
|
|
@ -680,44 +680,44 @@ static bool test_plato_english_iso8859_cp850_handle(struct torture_context *tctx
|
|
|
|
|
torture_assert_int_equal(tctx, plato_english_output.length, 5, "short conversion failed");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF16LE, CH_UNIX,
|
|
|
|
|
plato_english_utf16le.data, plato_english_utf16le.length,
|
|
|
|
|
CH_UTF16LE, CH_UNIX,
|
|
|
|
|
plato_english_utf16le.data, plato_english_utf16le.length,
|
|
|
|
|
(void *)&plato_english_output.data, &plato_english_output.length),
|
|
|
|
|
"conversion from UTF16LE to (unix charset) CP850");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, plato_english_output, plato_english_cp850, "conversion from UTF16LE to (unix charset) CP850 incorrect");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF16LE, CH_UTF8,
|
|
|
|
|
plato_english_utf16le.data, plato_english_utf16le.length,
|
|
|
|
|
(void *)&plato_english_output.data, &plato_english_output.length),
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF16LE, CH_UTF8,
|
|
|
|
|
plato_english_utf16le.data, plato_english_utf16le.length,
|
|
|
|
|
(void *)&plato_english_output.data, &plato_english_output.length),
|
|
|
|
|
"conversion from UTF16LE to UTF8");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, plato_english_output, plato_english_utf8, "conversion from UTF16LE to UTF8 incorrect");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_DOS, CH_DOS,
|
|
|
|
|
plato_english_iso8859_1.data, plato_english_iso8859_1.length,
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_DOS, CH_DOS,
|
|
|
|
|
plato_english_iso8859_1.data, plato_english_iso8859_1.length,
|
|
|
|
|
(void *)&plato_english_output.data, &plato_english_output.length),
|
|
|
|
|
"conversion from (dos charset) ISO-8859-1 to (dos charset) ISO-8859-1");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, plato_english_output, plato_english_iso8859_1, "conversion from UTF16LE to (dos charset) ISO-8859-1 incorrect");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_DOS, CH_UNIX,
|
|
|
|
|
plato_english_iso8859_1.data, plato_english_iso8859_1.length,
|
|
|
|
|
(void *)&plato_english_output.data, &plato_english_output.length),
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_DOS, CH_UNIX,
|
|
|
|
|
plato_english_iso8859_1.data, plato_english_iso8859_1.length,
|
|
|
|
|
(void *)&plato_english_output.data, &plato_english_output.length),
|
|
|
|
|
"conversion from (dos charset) ISO-8859-1 to (unix charset) CP850");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, plato_english_output, plato_english_cp850, "conversion from UTF16LE to (unix charset) CP850 incorrect");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_DOS, CH_UTF8,
|
|
|
|
|
plato_english_iso8859_1.data, plato_english_iso8859_1.length,
|
|
|
|
|
(void *)&plato_english_output.data, &plato_english_output.length),
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_DOS, CH_UTF8,
|
|
|
|
|
plato_english_iso8859_1.data, plato_english_iso8859_1.length,
|
|
|
|
|
(void *)&plato_english_output.data, &plato_english_output.length),
|
|
|
|
|
"conversion from (dos charset) ISO-8859-1 to UTF8");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, plato_english_output, plato_english_utf8, "conversion from UTF16LE to UTF8 incorrect");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_DOS, CH_UTF16LE,
|
|
|
|
|
plato_english_iso8859_1.data, plato_english_iso8859_1.length,
|
|
|
|
|
(void *)&plato_english_output.data, &plato_english_output.length),
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_DOS, CH_UTF16LE,
|
|
|
|
|
plato_english_iso8859_1.data, plato_english_iso8859_1.length,
|
|
|
|
|
(void *)&plato_english_output.data, &plato_english_output.length),
|
|
|
|
|
"conversion from (dos charset) ISO-8859-1 to UTF16LE");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, plato_english_output, plato_english_utf16le, "conversion from (dos charset) ISO-8859-1 to UTF16LE");
|
|
|
|
|
return true;
|
|
|
|
@ -731,10 +731,10 @@ static bool test_plato_english_minus_1_handle(struct torture_context *tctx)
|
|
|
|
|
DATA_BLOB plato_english_output;
|
|
|
|
|
DATA_BLOB plato_english_utf8_terminated;
|
|
|
|
|
DATA_BLOB plato_english_utf16le_terminated;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
talloc_steal(tctx, plato_english_utf16le.data);
|
|
|
|
|
|
|
|
|
|
iconv_handle = get_iconv_testing_handle(tctx, "ISO-8859-1", "CP850",
|
|
|
|
|
iconv_handle = get_iconv_testing_handle(tctx, "ISO-8859-1", "CP850",
|
|
|
|
|
lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true));
|
|
|
|
|
torture_assert(tctx, iconv_handle, "getting iconv handle");
|
|
|
|
|
|
|
|
|
@ -746,7 +746,7 @@ static bool test_plato_english_minus_1_handle(struct torture_context *tctx)
|
|
|
|
|
memcpy(plato_english_utf16le_terminated.data, plato_english_utf16le.data, plato_english_utf16le.length);
|
|
|
|
|
plato_english_utf16le_terminated.data[plato_english_utf16le.length] = '\0';
|
|
|
|
|
plato_english_utf16le_terminated.data[plato_english_utf16le.length + 1] = '\0';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plato_english_output = data_blob_talloc(tctx, NULL, plato_english_utf16le.length + 10);
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_error_handle(iconv_handle,
|
|
|
|
@ -835,11 +835,11 @@ static bool test_plato_english_minus_1_handle(struct torture_context *tctx)
|
|
|
|
|
"conversion from UTF16LE to UTF8 null terminated");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, plato_english_output, plato_english_utf8_terminated, "conversion from UTF16LE to UTF8 null terminated early");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Now null terminate the string particularly early, the confirm we don't skip the NULL and convert any further */
|
|
|
|
|
plato_english_utf8_terminated.data[1] = '\0';
|
|
|
|
|
plato_english_utf8_terminated.length = 2; /* used for the comparison only */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plato_english_utf16le_terminated.data[2] = '\0';
|
|
|
|
|
plato_english_utf16le_terminated.data[3] = '\0';
|
|
|
|
|
plato_english_utf16le_terminated.length = 4; /* used for the comparison only */
|
|
|
|
@ -872,7 +872,7 @@ static bool test_plato_minus_1_handle(struct torture_context *tctx)
|
|
|
|
|
DATA_BLOB plato_output;
|
|
|
|
|
DATA_BLOB plato_utf8_terminated;
|
|
|
|
|
DATA_BLOB plato_utf16le_terminated;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
talloc_steal(tctx, plato_utf8.data);
|
|
|
|
|
talloc_steal(tctx, plato_utf16le.data);
|
|
|
|
|
|
|
|
|
@ -976,7 +976,7 @@ static bool test_plato_minus_1_handle(struct torture_context *tctx)
|
|
|
|
|
(void *)plato_output.data, plato_output.length, &plato_output.length),
|
|
|
|
|
"conversion from UTF16LE to UTF8 null terminated");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, plato_output, plato_utf8_terminated, "conversion from UTF16LE to UTF8 null terminated early");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -987,15 +987,15 @@ static bool test_plato_cp850_utf8_handle(struct torture_context *tctx)
|
|
|
|
|
DATA_BLOB plato_utf16le = base64_decode_data_blob(plato_utf16le_base64);
|
|
|
|
|
DATA_BLOB plato_output;
|
|
|
|
|
DATA_BLOB plato_output2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
talloc_steal(tctx, plato_utf8.data);
|
|
|
|
|
talloc_steal(tctx, plato_utf16le.data);
|
|
|
|
|
|
|
|
|
|
iconv_handle = get_iconv_testing_handle(tctx, "CP850", "UTF8",
|
|
|
|
|
iconv_handle = get_iconv_testing_handle(tctx, "CP850", "UTF8",
|
|
|
|
|
lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true));
|
|
|
|
|
torture_assert(tctx, iconv_handle, "creating iconv handle");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_UTF16LE,
|
|
|
|
|
plato_utf8.data, plato_utf8.length,
|
|
|
|
|
(void *)&plato_output.data, &plato_output.length),
|
|
|
|
@ -1055,18 +1055,18 @@ static bool test_plato_cp850_utf8_handle(struct torture_context *tctx)
|
|
|
|
|
"conversion of UTF8 to UTF8");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_DOS,
|
|
|
|
|
plato_utf8.data, plato_utf8.length,
|
|
|
|
|
(void *)&plato_output.data, &plato_output.length) == false,
|
|
|
|
|
CH_UTF8, CH_DOS,
|
|
|
|
|
plato_utf8.data, plato_utf8.length,
|
|
|
|
|
(void *)&plato_output.data, &plato_output.length) == false,
|
|
|
|
|
"conversion of UTF8 ancient greek to DOS charset CP850 should fail");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_UNIX,
|
|
|
|
|
plato_utf8.data, plato_utf8.length,
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_UNIX,
|
|
|
|
|
plato_utf8.data, plato_utf8.length,
|
|
|
|
|
(void *)&plato_output.data, &plato_output.length),
|
|
|
|
|
"conversion of UTF16 ancient greek to unix charset UTF8 failed");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, plato_output, plato_utf8, "conversion from UTF8 to (unix charset) UTF8 incorrect");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memset(plato_output.data, '\0', plato_output.length);
|
|
|
|
|
torture_assert(tctx, convert_string_error_handle(iconv_handle,
|
|
|
|
|
CH_UTF8, CH_UNIX,
|
|
|
|
@ -1076,17 +1076,17 @@ static bool test_plato_cp850_utf8_handle(struct torture_context *tctx)
|
|
|
|
|
"conversion of UTF16 ancient greek to unix charset UTF8 failed");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, plato_output, plato_utf8, "conversion from UTF8 to (unix charset) UTF8 incorrect");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_UTF8,
|
|
|
|
|
plato_utf8.data, plato_utf8.length,
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_UTF8,
|
|
|
|
|
plato_utf8.data, plato_utf8.length,
|
|
|
|
|
(void *)&plato_output.data, &plato_output.length),
|
|
|
|
|
"conversion of UTF16 ancient greek to unix charset UTF8 failed");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, plato_output, plato_utf8, "conversion from UTF8 to UTF8 incorrect");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF16LE, CH_DOS,
|
|
|
|
|
plato_utf16le.data, plato_utf16le.length,
|
|
|
|
|
(void *)&plato_output.data, &plato_output.length) == false,
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF16LE, CH_DOS,
|
|
|
|
|
plato_utf16le.data, plato_utf16le.length,
|
|
|
|
|
(void *)&plato_output.data, &plato_output.length) == false,
|
|
|
|
|
"conversion of UTF16 ancient greek to DOS charset CP850 should fail");
|
|
|
|
|
|
|
|
|
|
/* Allocate enough space, if it were possible do do the conversion */
|
|
|
|
@ -1123,10 +1123,10 @@ static bool test_plato_cp850_utf8_handle(struct torture_context *tctx)
|
|
|
|
|
"conversion of UTF16 ancient greek to UTF8 should stop on multibyte boundary");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF16LE, CH_UNIX,
|
|
|
|
|
plato_utf16le.data, plato_utf16le.length,
|
|
|
|
|
(void *)&plato_output.data, &plato_output.length),
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF16LE, CH_UNIX,
|
|
|
|
|
plato_utf16le.data, plato_utf16le.length,
|
|
|
|
|
(void *)&plato_output.data, &plato_output.length),
|
|
|
|
|
"conversion of UTF16 ancient greek to unix charset UTF8 failed");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, plato_output, plato_utf8, "conversion from UTF16LE to (unix charset) UTF8 incorrect");
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
@ -1135,16 +1135,16 @@ static bool test_plato_cp850_utf8_handle(struct torture_context *tctx)
|
|
|
|
|
(void *)&plato_output.data, &plato_output.length),
|
|
|
|
|
"conversion of UTF16 ancient greek to UTF8 failed");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, plato_output, plato_utf8, "conversion from UTF16LE to UTF8 incorrect");
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF16LE, CH_UTF8,
|
|
|
|
|
plato_utf16le.data, plato_utf16le.length,
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF16LE, CH_UTF8,
|
|
|
|
|
plato_utf16le.data, plato_utf16le.length,
|
|
|
|
|
(void *)&plato_output.data, &plato_output.length),
|
|
|
|
|
"conversion of UTF16 ancient greek to UTF8 failed");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, plato_output, plato_utf8, "conversion from UTF16LE to UTF8 incorrect");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_UTF16LE,
|
|
|
|
|
plato_output.data, plato_output.length,
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_UTF16LE,
|
|
|
|
|
plato_output.data, plato_output.length,
|
|
|
|
|
(void *)&plato_output2.data, &plato_output2.length),
|
|
|
|
|
"round trip conversion of UTF16 ancient greek to UTF8 and back again failed");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, plato_output2, plato_utf16le,
|
|
|
|
@ -1179,57 +1179,57 @@ static bool test_plato_latin_cp850_utf8_handle(struct torture_context *tctx)
|
|
|
|
|
DATA_BLOB plato_latin_utf16le = base64_decode_data_blob(plato_latin_utf16le_base64);
|
|
|
|
|
DATA_BLOB plato_latin_output;
|
|
|
|
|
DATA_BLOB plato_latin_output2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
talloc_steal(tctx, plato_latin_utf8.data);
|
|
|
|
|
talloc_steal(tctx, plato_latin_utf16le.data);
|
|
|
|
|
|
|
|
|
|
iconv_handle = get_iconv_testing_handle(tctx, "CP850", "UTF8",
|
|
|
|
|
lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "use_builtin_handlers", true));
|
|
|
|
|
torture_assert(tctx, iconv_handle, "creating iconv handle");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_DOS,
|
|
|
|
|
plato_latin_utf8.data, plato_latin_utf8.length,
|
|
|
|
|
(void *)&plato_latin_output.data, &plato_latin_output.length) == false,
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_DOS,
|
|
|
|
|
plato_latin_utf8.data, plato_latin_utf8.length,
|
|
|
|
|
(void *)&plato_latin_output.data, &plato_latin_output.length) == false,
|
|
|
|
|
"conversion of UTF8 latin charset greek to DOS charset CP850 should fail");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_UNIX,
|
|
|
|
|
plato_latin_utf8.data, plato_latin_utf8.length,
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_UNIX,
|
|
|
|
|
plato_latin_utf8.data, plato_latin_utf8.length,
|
|
|
|
|
(void *)&plato_latin_output.data, &plato_latin_output.length),
|
|
|
|
|
"conversion of UTF16 latin charset greek to unix charset UTF8 failed");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, plato_latin_output, plato_latin_utf8, "conversion from UTF8 to (unix charset) UTF8 incorrect");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_UTF8,
|
|
|
|
|
plato_latin_utf8.data, plato_latin_utf8.length,
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_UTF8,
|
|
|
|
|
plato_latin_utf8.data, plato_latin_utf8.length,
|
|
|
|
|
(void *)&plato_latin_output.data, &plato_latin_output.length),
|
|
|
|
|
"conversion of UTF16 latin charset greek to unix charset UTF8 failed");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, plato_latin_output, plato_latin_utf8, "conversion from UTF8 to UTF8 incorrect");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF16LE, CH_DOS,
|
|
|
|
|
plato_latin_utf16le.data, plato_latin_utf16le.length,
|
|
|
|
|
(void *)&plato_latin_output.data, &plato_latin_output.length) == false,
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF16LE, CH_DOS,
|
|
|
|
|
plato_latin_utf16le.data, plato_latin_utf16le.length,
|
|
|
|
|
(void *)&plato_latin_output.data, &plato_latin_output.length) == false,
|
|
|
|
|
"conversion of UTF16 latin charset greek to DOS charset CP850 should fail");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF16LE, CH_UNIX,
|
|
|
|
|
plato_latin_utf16le.data, plato_latin_utf16le.length,
|
|
|
|
|
(void *)&plato_latin_output.data, &plato_latin_output.length),
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF16LE, CH_UNIX,
|
|
|
|
|
plato_latin_utf16le.data, plato_latin_utf16le.length,
|
|
|
|
|
(void *)&plato_latin_output.data, &plato_latin_output.length),
|
|
|
|
|
"conversion of UTF16 latin charset greek to unix charset UTF8 failed");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, plato_latin_output, plato_latin_utf8, "conversion from UTF16LE to (unix charset) CP850 incorrect");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF16LE, CH_UTF8,
|
|
|
|
|
plato_latin_utf16le.data, plato_latin_utf16le.length,
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF16LE, CH_UTF8,
|
|
|
|
|
plato_latin_utf16le.data, plato_latin_utf16le.length,
|
|
|
|
|
(void *)&plato_latin_output.data, &plato_latin_output.length),
|
|
|
|
|
"conversion of UTF16 latin charset greek to UTF8 failed");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, plato_latin_output, plato_latin_utf8, "conversion from UTF16LE to UTF8 incorrect");
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_UTF16LE,
|
|
|
|
|
plato_latin_output.data, plato_latin_output.length,
|
|
|
|
|
|
|
|
|
|
torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
|
|
|
|
|
CH_UTF8, CH_UTF16LE,
|
|
|
|
|
plato_latin_output.data, plato_latin_output.length,
|
|
|
|
|
(void *)&plato_latin_output2.data, &plato_latin_output2.length),
|
|
|
|
|
"round trip conversion of UTF16 latin charset greek to UTF8 and back again failed");
|
|
|
|
|
torture_assert_data_blob_equal(tctx, plato_latin_output2, plato_latin_utf16le,
|
|
|
|
|