about summary refs log tree commit diff stats
path: root/unittests/test_cmd_sub.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-05-28 18:50:55 +0100
committerJames Booth <boothj5@gmail.com>2015-05-28 18:50:55 +0100
commit6d6bb6458873196f904257cd00a6f2221262783d (patch)
tree2b751a3e8cc54dc487a95703898fc9a96e438dbf /unittests/test_cmd_sub.c
parent0c99dc7ad60843aa7719a9c75aa701e3c86720da (diff)
downloadprofani-tty-6d6bb6458873196f904257cd00a6f2221262783d.tar.gz
Moved tests -> unittests
Diffstat (limited to 'unittests/test_cmd_sub.c')
-rw-r--r--unittests/test_cmd_sub.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/unittests/test_cmd_sub.c b/unittests/test_cmd_sub.c
new file mode 100644
index 00000000..80b85f15
--- /dev/null
+++ b/unittests/test_cmd_sub.c
@@ -0,0 +1,45 @@
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <cmocka.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+
+#include "xmpp/xmpp.h"
+
+#include "ui/ui.h"
+#include "ui/stub_ui.h"
+
+#include "command/commands.h"
+
+void cmd_sub_shows_message_when_not_connected(void **state)
+{
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    gchar *args[] = { NULL };
+
+    will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
+
+    expect_cons_show("You are currently not connected.");
+
+    gboolean result = cmd_sub(args, *help);
+    assert_true(result);
+
+    free(help);
+}
+
+void cmd_sub_shows_usage_when_no_arg(void **state)
+{
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    help->usage = "Some usage";
+    gchar *args[] = { NULL };
+
+    will_return(jabber_get_connection_status, JABBER_CONNECTED);
+
+    expect_cons_show("Usage: Some usage");
+
+    gboolean result = cmd_sub(args, *help);
+    assert_true(result);
+
+    free(help);
+}