* Input conversion stopped due to an incomplete character or shift
* sequence at the end of the input buffer.
*/
-static int test_iconv_incomplete_multibyte_is_einval() {
+static int test_iconv_incomplete_multibyte_is_einval(char* suffix) {
iconv_t cd;
- const char* tocode = "UTF-8";
+ const char* fromcode = "UTF-8";
+ char* tocode = malloc(strlen(fromcode) + strlen(suffix) + 1);
+ sprintf(tocode, "%s%s", fromcode, suffix);
+
+ char msg[59];
+ char* tpl;
+ if (strlen(suffix) == 0) {
+ // Don't print the suffix, but do avoid warnings about
+ // the missing argument.
+ tpl = "iconv() incomplete multibyte is EINVAL%s...";
+ }
+ else {
+ tpl = "iconv() incomplete multibyte is EINVAL (%s)...";
+ }
+ snprintf(msg, 59, tpl, suffix);
+ printf("%-60s", msg);
+
- printf("%-60s", "iconv() returns EINVAL on incomplete multibyte...");
if (_my_iconv_open(&cd, tocode, tocode) == FAILURE) {
printf("ERROR (iconv_open)\n");
return FAILURE;
result |= test_iconv_invalid_char_is_eilseq();
result |= test_iconv_too_big_is_e2big();
- result |= test_iconv_incomplete_multibyte_is_einval();
+ result |= test_iconv_incomplete_multibyte_is_einval("");
result |= test_iconv_untranslatable();
if (ignore == SUCCESS) {
result |= test_iconv_ignore_ignores_invalid();
result |= test_iconv_suffix_drops_untranslatable("//IGNORE");
- //result |= test_iconv_ignore_does_not_ignore_incomplete_multibyte();
+ result |= test_iconv_incomplete_multibyte_is_einval("//IGNORE");
}
if (translit == SUCCESS) {
result |= test_translit_does_not_fail_on_untranslatable();
- //result |= test_translit_fails_on_incomplete_multibyte();
+ result |= test_iconv_incomplete_multibyte_is_einval("//TRANSLIT");
+
}
if (non_identical_discard == SUCCESS) {
result |= test_iconv_suffix_drops_untranslatable("//NON_IDENTICAL_DISCARD");
- //result |= test_nid_fails_on_incomplete_multibyte();
+ result |= test_iconv_incomplete_multibyte_is_einval("//NON_IDENTICAL_DISCARD");
}
return result;