From 60e03094c3fd066283468fe094625bbd5a9a27ff Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 16 Feb 2014 14:44:40 +0000 Subject: Added test for /otr libver --- tests/test_cmd_otr.c | 18 ++++++++++++++++++ tests/test_cmd_otr.h | 1 + tests/testsuite.c | 1 + 3 files changed, 20 insertions(+) diff --git a/tests/test_cmd_otr.c b/tests/test_cmd_otr.c index 124f52f9..8bc25fcd 100644 --- a/tests/test_cmd_otr.c +++ b/tests/test_cmd_otr.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "config.h" #include "config/preferences.h" @@ -238,6 +239,23 @@ void cmd_otr_warn_off_disables_unencrypted_warning(void **state) free(help); } +void cmd_otr_libver_shows_libotr_version(void **state) +{ + mock_cons_show(); + CommandHelp *help = malloc(sizeof(CommandHelp)); + gchar *args[] = { "libver", NULL }; + + char *version = OTRL_VERSION; + GString *message = g_string_new("Using libotr version "); + g_string_append(message, version); + + expect_cons_show(message->str); + gboolean result = cmd_otr(args, *help); + assert_true(result); + + g_string_free(message, TRUE); + free(help); +} #else void cmd_otr_shows_message_when_otr_unsupported(void **state) { diff --git a/tests/test_cmd_otr.h b/tests/test_cmd_otr.h index bfb39a2d..137d7e7d 100644 --- a/tests/test_cmd_otr.h +++ b/tests/test_cmd_otr.h @@ -14,6 +14,7 @@ void cmd_otr_warn_shows_usage_when_no_args(void **state); void cmd_otr_warn_shows_usage_when_invalid_arg(void **state); void cmd_otr_warn_on_enables_unencrypted_warning(void **state); void cmd_otr_warn_off_disables_unencrypted_warning(void **state); +void cmd_otr_libver_shows_libotr_version(void **state); #else void cmd_otr_shows_message_when_otr_unsupported(void **state); #endif diff --git a/tests/testsuite.c b/tests/testsuite.c index 0a34bad2..38e535aa 100644 --- a/tests/testsuite.c +++ b/tests/testsuite.c @@ -455,6 +455,7 @@ int main(int argc, char* argv[]) { unit_test_setup_teardown(cmd_otr_warn_off_disables_unencrypted_warning, init_preferences, close_preferences), + unit_test(cmd_otr_libver_shows_libotr_version), #else unit_test(cmd_otr_shows_message_when_otr_unsupported), #endif -- cgit 1.4.1-2-gfad0