test error messages
This commit is contained in:
parent
b5672070b6
commit
0931a29649
2 changed files with 16 additions and 2 deletions
4
main.c
4
main.c
|
@ -94,10 +94,10 @@ static int process_string(const char *input, unsigned int flags)
|
||||||
fprintf(stdout, "%s", output);
|
fprintf(stdout, "%s", output);
|
||||||
break;
|
break;
|
||||||
case EHINDI:
|
case EHINDI:
|
||||||
error("the input text is Hindi");
|
error("the input text is Hindi.");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error("unexpected error");
|
error("unexpected error.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,19 @@ START_TEST(test_usage)
|
||||||
out[44] = '\0'; /* the first line is enough here */
|
out[44] = '\0'; /* the first line is enough here */
|
||||||
ck_assert_str_eq("iast, a helper for Sanskrit transliteration.", out);
|
ck_assert_str_eq("iast, a helper for Sanskrit transliteration.", out);
|
||||||
free(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
|
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_velthuis);
|
||||||
tcase_add_test(test_case, test_version);
|
tcase_add_test(test_case, test_version);
|
||||||
tcase_add_test(test_case, test_usage);
|
tcase_add_test(test_case, test_usage);
|
||||||
|
tcase_add_test(test_case, test_errors);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue