about summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-07-04 00:41:29 +0100
committerJames Booth <boothj5@gmail.com>2016-07-04 00:41:29 +0100
commit71879a3f64f5f04cdceeedf0317175b2bab1701c (patch)
treed97c05b977718ef679892468e449a72972db99ae /tests
parent606a860bdc2fd93773405655be467064aa949cc6 (diff)
downloadprofani-tty-71879a3f64f5f04cdceeedf0317175b2bab1701c.tar.gz
Free plugins commands on quit
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/test_callbacks.c32
-rw-r--r--tests/unittests/test_callbacks.h2
-rw-r--r--tests/unittests/ui/stub_ui.c2
-rw-r--r--tests/unittests/unittests.c4
4 files changed, 39 insertions, 1 deletions
diff --git a/tests/unittests/test_callbacks.c b/tests/unittests/test_callbacks.c
new file mode 100644
index 00000000..32959aa7
--- /dev/null
+++ b/tests/unittests/test_callbacks.c
@@ -0,0 +1,32 @@
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <cmocka.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+
+#include "plugins/callbacks.h"
+#include "plugins/plugins.h"
+
+void returns_no_commands(void **state)
+{
+    callbacks_init();
+    GList *commands = plugins_get_command_names();
+
+    assert_true(commands == NULL);
+}
+
+void returns_commands(void **state)
+{
+    callbacks_init();
+    PluginCommand *command = malloc(sizeof(PluginCommand));
+    command->command_name = strdup("something");
+    callbacks_add_command("Cool plugin", command);
+
+    GList *commands = plugins_get_command_names();
+    assert_true(g_list_length(commands) == 1);
+
+    char *name = commands->data;
+    assert_string_equal(name, "something");
+}
diff --git a/tests/unittests/test_callbacks.h b/tests/unittests/test_callbacks.h
new file mode 100644
index 00000000..35751d2e
--- /dev/null
+++ b/tests/unittests/test_callbacks.h
@@ -0,0 +1,2 @@
+void returns_no_commands(void **state);
+void returns_commands(void **state);
diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c
index 5e86799a..b0635fb8 100644
--- a/tests/unittests/ui/stub_ui.c
+++ b/tests/unittests/ui/stub_ui.c
@@ -265,7 +265,7 @@ void mucconfwin_show_form(ProfMucConfWin *confwin) {}
 void mucconfwin_show_form_field(ProfMucConfWin *confwin, DataForm *form, char *tag) {}
 void mucconfwin_form_help(ProfMucConfWin *confwin) {}
 void mucconfwin_field_help(ProfMucConfWin *confwin, char *tag) {}
-void ui_show_lines(ProfWin *window, const gchar** lines) {}
+void ui_show_lines(ProfWin *window, gchar** lines) {}
 void ui_redraw_all_room_rosters(void) {}
 void ui_show_all_room_rosters(void) {}
 void ui_hide_all_room_rosters(void) {}
diff --git a/tests/unittests/unittests.c b/tests/unittests/unittests.c
index 5577104e..91fb3cb2 100644
--- a/tests/unittests/unittests.c
+++ b/tests/unittests/unittests.c
@@ -33,6 +33,7 @@
 #include "test_cmd_roster.h"
 #include "test_cmd_disconnect.h"
 #include "test_form.h"
+#include "test_callbacks.h"
 
 int main(int argc, char* argv[]) {
     const UnitTest all_tests[] = {
@@ -602,6 +603,9 @@ int main(int argc, char* argv[]) {
 
         unit_test(prof_partial_occurrences_tests),
         unit_test(prof_whole_occurrences_tests),
+
+        unit_test(returns_no_commands),
+        unit_test(returns_commands),
     };
 
     return run_tests(all_tests);