From 0931a29649741e23fe362f0cc87eaedf1641a4c7 Mon Sep 17 00:00:00 2001 From: Vlasta Vesely Date: Sat, 13 Mar 2021 16:15:40 +0100 Subject: [PATCH] test error messages --- main.c | 4 ++-- tests/integration.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index f94c64f..1463e8c 100644 --- a/main.c +++ b/main.c @@ -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; } diff --git a/tests/integration.c b/tests/integration.c index 2583dd9..3e43707 100644 --- a/tests/integration.c +++ b/tests/integration.c @@ -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); }