test error messages

This commit is contained in:
Vlasta Vesely 2021-03-13 16:15:40 +01:00
parent b5672070b6
commit 0931a29649
2 changed files with 16 additions and 2 deletions

4
main.c
View file

@ -94,10 +94,10 @@ static int process_string(const char *input, unsigned int flags)
fprintf(stdout, "%s", output);
break;
case EHINDI:
error("the input text is Hindi");
error("the input text is Hindi.");
break;
default:
error("unexpected error");
error("unexpected error.");
break;
}

View file

@ -117,6 +117,19 @@ START_TEST(test_usage)
out[44] = '\0'; /* the first line is enough here */
ck_assert_str_eq("iast, a helper for Sanskrit transliteration.", out);
free(out);
out = exec_command("./iast -h");
out[44] = '\0';
ck_assert_str_eq("iast, a helper for Sanskrit transliteration.", out);
free(out);
}
END_TEST
START_TEST(test_errors)
{
test_output("./iast -x 2>&1", "[iast] error: unrecognised option '-x'.\n");
test_output("./iast -f xxx 2>&1", "[iast] error: failed to read file 'xxx'.\n");
test_output("./iast \u0921\u093c 2>&1", "[iast] error: the input text is Hindi.\n");
}
END_TEST
@ -128,4 +141,5 @@ void register_integration_tests(TCase *test_case)
tcase_add_test(test_case, test_velthuis);
tcase_add_test(test_case, test_version);
tcase_add_test(test_case, test_usage);
tcase_add_test(test_case, test_errors);
}