Add Framework for queues tests
This commit is contained in:
parent
cb16fe9d96
commit
e04003e291
@ -1,6 +1,7 @@
|
|||||||
/* copyright 2012 - 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */
|
/* 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
|
* @brief logging wrapper to use GLib's logging capabilities
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */
|
/* 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
|
* @brief All important functions to handle the notification queues for
|
||||||
* history, entrance and currently displayed ones.
|
* history, entrance and currently displayed ones.
|
||||||
*
|
*
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */
|
/* copyright 2013 Sascha Kruse and contributors (see LICENSE for licensing information) */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file queues.c
|
* @file src/queues.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef DUNST_QUEUE_H
|
#ifndef DUNST_QUEUE_H
|
||||||
|
20
test/queues.c
Normal file
20
test/queues.c
Normal file
@ -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: */
|
48
test/queues.h
Normal file
48
test/queues.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#include "greatest.h"
|
||||||
|
|
||||||
|
#ifndef DUNST_TEST_QUEUES_H
|
||||||
|
#define DUNST_TEST_QUEUES_H
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
#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: */
|
@ -15,6 +15,7 @@ SUITE_EXTERN(suite_notification);
|
|||||||
SUITE_EXTERN(suite_markup);
|
SUITE_EXTERN(suite_markup);
|
||||||
SUITE_EXTERN(suite_misc);
|
SUITE_EXTERN(suite_misc);
|
||||||
SUITE_EXTERN(suite_icon);
|
SUITE_EXTERN(suite_icon);
|
||||||
|
SUITE_EXTERN(suite_queues);
|
||||||
|
|
||||||
GREATEST_MAIN_DEFS();
|
GREATEST_MAIN_DEFS();
|
||||||
|
|
||||||
@ -36,6 +37,7 @@ int main(int argc, char *argv[]) {
|
|||||||
RUN_SUITE(suite_markup);
|
RUN_SUITE(suite_markup);
|
||||||
RUN_SUITE(suite_misc);
|
RUN_SUITE(suite_misc);
|
||||||
RUN_SUITE(suite_icon);
|
RUN_SUITE(suite_icon);
|
||||||
|
RUN_SUITE(suite_queues);
|
||||||
GREATEST_MAIN_END();
|
GREATEST_MAIN_END();
|
||||||
|
|
||||||
base = NULL;
|
base = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user