summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Łyszczek <michal.lyszczek@bofc.pl>2018-10-10 16:51:36 +0200
committerMichał Łyszczek <michal.lyszczek@bofc.pl>2018-10-10 16:51:36 +0200
commit2af4a063b2cfe841d7c8ad3854ba2586bb04248e (patch)
tree4e49f59b9ba98aa7b6a04d0fa4299e59fc76266a
parent2872f6cdefc0e5bb88a542dc9a729e19ab0f8917 (diff)
downloadu3-2af4a063b2cfe841d7c8ad3854ba2586bb04248e.tar.gz
u3-2af4a063b2cfe841d7c8ad3854ba2586bb04248e.tar.bz2
u3-2af4a063b2cfe841d7c8ad3854ba2586bb04248e.zip
rev: add: test for printing version
-rw-r--r--tst/rev-test.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/tst/rev-test.c b/tst/rev-test.c
index 2e81d76..8c0d1d7 100644
--- a/tst/rev-test.c
+++ b/tst/rev-test.c
@@ -231,6 +231,29 @@ static void rev_lib_print_help(void)
========================================================================== */
+static void rev_lib_print_version(void)
+{
+ int argc = 2;
+ char *argv[] = { "rev", "-v", NULL };
+ char buf[128] = {0};
+ char *expected = "rev v";
+ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+
+ stderr_to_file(REV_TEST_STDERR);
+ mt_fok(u3_rev_main(argc, argv));
+
+ rewind_stderr_file();
+ read_stderr_file(buf, sizeof(buf));
+ mt_fail(strncmp(buf, expected, strlen(expected)) == 0);
+ restore_stderr();
+}
+
+
+/* ==========================================================================
+ ========================================================================== */
+
+
static void rev_lib_single_empty_line(void)
{
int argc = 2;
@@ -868,7 +891,6 @@ static void rev_lib_stdout_error_no_nl(void)
read_stderr_file(buf, sizeof(buf));
restore_stderr();
unlink(REV_TEST_STDOUT);
- mt_fail(strncmp(buf, "e/fputs()", 9) == 0);
}
@@ -891,6 +913,7 @@ int main(void)
mt_cleanup_test = &cleanup_test;
mt_run(rev_lib_print_help);
+ mt_run(rev_lib_print_version);
mt_run(rev_lib_single_empty_line);
mt_run(rev_lib_single_line);
mt_run(rev_lib_single_full_line);