about summary refs log tree commit diff stats
path: root/tests/unittests/test_cmd_bookmark.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-07-27 00:04:48 +0100
committerJames Booth <boothj5@gmail.com>2015-07-27 00:04:48 +0100
commit8119025120b0b511aea8bc3f477d2aff835bd24b (patch)
tree14d19a151bc8aa0862002a2da8feb10a7a89b788 /tests/unittests/test_cmd_bookmark.c
parent59d5dd73a77b2a85e199ad43e9ba4591b2bfbe08 (diff)
downloadprofani-tty-8119025120b0b511aea8bc3f477d2aff835bd24b.tar.gz
Fixed tests for new command format
Diffstat (limited to 'tests/unittests/test_cmd_bookmark.c')
-rw-r--r--tests/unittests/test_cmd_bookmark.c58
1 files changed, 15 insertions, 43 deletions
diff --git a/tests/unittests/test_cmd_bookmark.c b/tests/unittests/test_cmd_bookmark.c
index 04326f98..eafae9b6 100644
--- a/tests/unittests/test_cmd_bookmark.c
+++ b/tests/unittests/test_cmd_bookmark.c
@@ -20,17 +20,15 @@
 
 #include "helpers.h"
 
+#define CMD_BOOKMARK "/bookmark"
+
 static void test_with_connection_status(jabber_conn_status_t status)
 {
-    CommandHelp *help = malloc(sizeof(CommandHelp));
-
     will_return(jabber_get_connection_status, status);
     expect_cons_show("You are not currently connected.");
 
-    gboolean result = cmd_bookmark(NULL, NULL, *help);
+    gboolean result = cmd_bookmark(NULL, CMD_BOOKMARK, NULL);
     assert_true(result);
-
-    free(help);
 }
 
 void cmd_bookmark_shows_message_when_disconnected(void **state)
@@ -60,20 +58,16 @@ void cmd_bookmark_shows_message_when_undefined(void **state)
 
 void cmd_bookmark_shows_usage_when_no_args(void **state)
 {
-    CommandHelp *help = malloc(sizeof(CommandHelp));
-    help->usage = "some usage";
     gchar *args[] = { NULL };
     ProfWin window;
     window.type = WIN_CONSOLE;
 
     will_return(jabber_get_connection_status, JABBER_CONNECTED);
 
-    expect_cons_show("Usage: some usage");
+    expect_string(cons_bad_cmd_usage, cmd, CMD_BOOKMARK);
 
-    gboolean result = cmd_bookmark(&window, args, *help);
+    gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
     assert_true(result);
-
-    free(help);
 }
 
 static void _free_bookmark(Bookmark *bookmark)
@@ -101,7 +95,6 @@ _cmp_bookmark(Bookmark *bm1, Bookmark *bm2)
 
 void cmd_bookmark_list_shows_bookmarks(void **state)
 {
-    CommandHelp *help = malloc(sizeof(CommandHelp));
     gchar *args[] = { "list", NULL };
     GList *bookmarks = NULL;
     ProfWin window;
@@ -141,17 +134,15 @@ void cmd_bookmark_list_shows_bookmarks(void **state)
     glist_set_cmp((GCompareFunc)_cmp_bookmark);
     expect_any(cons_show_bookmarks, list);
 
-    gboolean result = cmd_bookmark(&window, args, *help);
+    gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
     assert_true(result);
 
-    free(help);
     g_list_free_full(bookmarks, (GDestroyNotify)_free_bookmark);
 }
 
 void cmd_bookmark_add_shows_message_when_invalid_jid(void **state)
 {
     char *jid = "room";
-    CommandHelp *help = malloc(sizeof(CommandHelp));
     gchar *args[] = { "add", jid, NULL };
     ProfWin window;
     window.type = WIN_CONSOLE;
@@ -160,16 +151,13 @@ void cmd_bookmark_add_shows_message_when_invalid_jid(void **state)
 
     expect_cons_show("Can't add bookmark with JID 'room'; should be 'room@domain.tld'");
 
-    gboolean result = cmd_bookmark(&window, args, *help);
+    gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
     assert_true(result);
-
-    free(help);
 }
 
 void cmd_bookmark_add_adds_bookmark_with_jid(void **state)
 {
     char *jid = "room@conf.server";
-    CommandHelp *help = malloc(sizeof(CommandHelp));
     gchar *args[] = { "add", jid, NULL };
     ProfWin window;
     window.type = WIN_CONSOLE;
@@ -184,16 +172,14 @@ void cmd_bookmark_add_adds_bookmark_with_jid(void **state)
 
     expect_cons_show("Bookmark added for room@conf.server.");
 
-    gboolean result = cmd_bookmark(&window, args, *help);
+    gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
     assert_true(result);
-
-    free(help);
 }
 
 void cmd_bookmark_add_adds_bookmark_with_jid_nick(void **state)
-{    char *jid = "room@conf.server";
+{
+    char *jid = "room@conf.server";
     char *nick = "bob";
-    CommandHelp *help = malloc(sizeof(CommandHelp));
     gchar *args[] = { "add", jid, "nick", nick, NULL };
     ProfWin window;
     window.type = WIN_CONSOLE;
@@ -208,16 +194,13 @@ void cmd_bookmark_add_adds_bookmark_with_jid_nick(void **state)
 
     expect_cons_show("Bookmark added for room@conf.server.");
 
-    gboolean result = cmd_bookmark(&window, args, *help);
+    gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
     assert_true(result);
-
-    free(help);
 }
 
 void cmd_bookmark_add_adds_bookmark_with_jid_autojoin(void **state)
 {
     char *jid = "room@conf.server";
-    CommandHelp *help = malloc(sizeof(CommandHelp));
     gchar *args[] = { "add", jid, "autojoin", "on", NULL };
     ProfWin window;
     window.type = WIN_CONSOLE;
@@ -232,17 +215,14 @@ void cmd_bookmark_add_adds_bookmark_with_jid_autojoin(void **state)
 
     expect_cons_show("Bookmark added for room@conf.server.");
 
-    gboolean result = cmd_bookmark(&window, args, *help);
+    gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
     assert_true(result);
-
-    free(help);
 }
 
 void cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin(void **state)
 {
     char *jid = "room@conf.server";
     char *nick = "bob";
-    CommandHelp *help = malloc(sizeof(CommandHelp));
     gchar *args[] = { "add", jid, "nick", nick, "autojoin", "on", NULL };
     ProfWin window;
     window.type = WIN_CONSOLE;
@@ -257,16 +237,13 @@ void cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin(void **state)
 
     expect_cons_show("Bookmark added for room@conf.server.");
 
-    gboolean result = cmd_bookmark(&window, args, *help);
+    gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
     assert_true(result);
-
-    free(help);
 }
 
 void cmd_bookmark_remove_removes_bookmark(void **state)
 {
     char *jid = "room@conf.server";
-    CommandHelp *help = malloc(sizeof(CommandHelp));
     gchar *args[] = { "remove", jid, NULL };
     ProfWin window;
     window.type = WIN_CONSOLE;
@@ -278,16 +255,13 @@ void cmd_bookmark_remove_removes_bookmark(void **state)
 
     expect_cons_show("Bookmark removed for room@conf.server.");
 
-    gboolean result = cmd_bookmark(&window, args, *help);
+    gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
     assert_true(result);
-
-    free(help);
 }
 
 void cmd_bookmark_remove_shows_message_when_no_bookmark(void **state)
 {
     char *jid = "room@conf.server";
-    CommandHelp *help = malloc(sizeof(CommandHelp));
     gchar *args[] = { "remove", jid, NULL };
     ProfWin window;
     window.type = WIN_CONSOLE;
@@ -299,8 +273,6 @@ void cmd_bookmark_remove_shows_message_when_no_bookmark(void **state)
 
     expect_cons_show("No bookmark exists for room@conf.server.");
 
-    gboolean result = cmd_bookmark(&window, args, *help);
+    gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
     assert_true(result);
-
-    free(help);
 }