diff --git a/src/log.c b/src/log.c index 3e51fb0..a5e7de7 100644 --- a/src/log.c +++ b/src/log.c @@ -1,6 +1,7 @@ /* copyright 2012 - 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */ -/** @file log.c +/** + * @file src/log.c * @brief logging wrapper to use GLib's logging capabilities */ diff --git a/src/queues.c b/src/queues.c index 6597247..427e6b9 100644 --- a/src/queues.c +++ b/src/queues.c @@ -1,7 +1,7 @@ /* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */ /** - * @file queues.c + * @file src/queues.c * @brief All important functions to handle the notification queues for * history, entrance and currently displayed ones. * diff --git a/src/queues.h b/src/queues.h index f0feaed..0b55a38 100644 --- a/src/queues.h +++ b/src/queues.h @@ -1,7 +1,7 @@ /* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */ /** - * @file queues.c + * @file src/queues.h */ #ifndef DUNST_QUEUE_H diff --git a/test/queues.c b/test/queues.c new file mode 100644 index 0000000..93f8c25 --- /dev/null +++ b/test/queues.c @@ -0,0 +1,20 @@ +#include "../src/queues.c" +#include "greatest.h" +#include "queues.h" + +TEST test_queue_init(void) +{ + queues_init(); + + QUEUE_LEN_ALL(0, 0, 0); + + queues_teardown(); + PASS(); +} + +SUITE(suite_queues) +{ + RUN_TEST(test_queue_init); +} + +/* vim: set tabstop=8 shiftwidth=8 expandtab textwidth=0: */ diff --git a/test/queues.h b/test/queues.h new file mode 100644 index 0000000..72bf29f --- /dev/null +++ b/test/queues.h @@ -0,0 +1,48 @@ +#include "greatest.h" + +#ifndef DUNST_TEST_QUEUES_H +#define DUNST_TEST_QUEUES_H + +#include +#include + +#include "../src/notification.h" +#include "../src/queues.h" + +#define QUEUE_WAIT waiting +#define QUEUE_DISP displayed +#define QUEUE_HIST history +#define QUEUE(q) QUEUE_##q + +#define QUEUE_LEN_ALL(wait, disp, hist) do { \ + if (wait >= 0) ASSERTm("Waiting is not " #wait, wait == g_queue_get_length(QUEUE(WAIT))); \ + if (disp >= 0) ASSERTm("Displayed is not " #disp, disp == g_queue_get_length(QUEUE(DISP))); \ + if (disp >= 0) ASSERTm("History is not " #hist, hist == g_queue_get_length(QUEUE(HIST))); \ + } while (0) + +#define QUEUE_CONTAINS(q, n) QUEUE_CONTAINSm("QUEUE_CONTAINS(" #q "," #n ")", q, n) +#define QUEUE_CONTAINSm(msg, q, n) ASSERTm(msg, g_queue_find(QUEUE(q), n)) + +#define NOT_LAST(n) do {ASSERT_EQm("Notification " #n " should have been deleted.", 1, notification_refcount_get(n)); g_clear_pointer(&n, notification_unref); } while(0) + +static inline struct notification *test_notification(const char *name, gint64 timeout) +{ + struct notification *n = notification_create(); + + if (timeout != -1) + n->timeout = S2US(timeout); + + n->dbus_client = g_strconcat(":", name, NULL); + n->appname = g_strconcat("app of ", name, NULL); + n->summary = g_strconcat(name, NULL); + n->body = g_strconcat("See, ", name, ", I've got a body for you!", NULL); + + n->format = "%s\n%b"; + + notification_init(n); + + return n; +} + +#endif +/* vim: set tabstop=8 shiftwidth=8 expandtab textwidth=0: */ diff --git a/test/test.c b/test/test.c index 432911d..7d2f6f4 100644 --- a/test/test.c +++ b/test/test.c @@ -15,6 +15,7 @@ SUITE_EXTERN(suite_notification); SUITE_EXTERN(suite_markup); SUITE_EXTERN(suite_misc); SUITE_EXTERN(suite_icon); +SUITE_EXTERN(suite_queues); GREATEST_MAIN_DEFS(); @@ -36,6 +37,7 @@ int main(int argc, char *argv[]) { RUN_SUITE(suite_markup); RUN_SUITE(suite_misc); RUN_SUITE(suite_icon); + RUN_SUITE(suite_queues); GREATEST_MAIN_END(); base = NULL;