From 0331cbe2490714607ffc3216cd2412d69c0ee283 Mon Sep 17 00:00:00 2001 From: James Booth Date: Fri, 27 Dec 2013 22:12:39 +0000 Subject: [PATCH] Test usage shown for /sub --- tests/test_cmd_sub.c | 17 +++++++++++++++++ tests/test_cmd_sub.h | 1 + tests/testsuite.c | 1 + 3 files changed, 19 insertions(+) diff --git a/tests/test_cmd_sub.c b/tests/test_cmd_sub.c index 4f459be3..d2447a91 100644 --- a/tests/test_cmd_sub.c +++ b/tests/test_cmd_sub.c @@ -29,3 +29,20 @@ void cmd_sub_shows_message_when_not_connected(void **state) free(help); } + +void cmd_sub_shows_usage_when_no_arg(void **state) +{ + mock_cons_show(); + CommandHelp *help = malloc(sizeof(CommandHelp)); + help->usage = "Some usage"; + gchar *args[] = { NULL }; + + mock_connection_status(JABBER_CONNECTED); + + expect_cons_show("Usage: Some usage"); + + gboolean result = cmd_sub(args, *help); + assert_true(result); + + free(help); +} diff --git a/tests/test_cmd_sub.h b/tests/test_cmd_sub.h index b8c95c1a..6e8addd3 100644 --- a/tests/test_cmd_sub.h +++ b/tests/test_cmd_sub.h @@ -1 +1,2 @@ void cmd_sub_shows_message_when_not_connected(void **state); +void cmd_sub_shows_usage_when_no_arg(void **state); diff --git a/tests/testsuite.c b/tests/testsuite.c index 1ffd2a71..c0e98b23 100644 --- a/tests/testsuite.c +++ b/tests/testsuite.c @@ -255,6 +255,7 @@ int main(int argc, char* argv[]) { unit_test(cmd_account_clear_shows_message_when_invalid_property), unit_test(cmd_sub_shows_message_when_not_connected), + unit_test(cmd_sub_shows_usage_when_no_arg), }; return run_tests(tests);