Index: set.h
===================================================================
--- set.h	(revision 8c073a6e77edd56bc3d58d6b4af2a40f005aacad)
+++ set.h	(revision 7738014d6a9ad81806ddb4e06092791dbd10b616)
@@ -26,4 +26,6 @@
 #ifndef __SET_H__
 #define __SET_H__
+
+struct set;
 
 /* This used to be specific to irc_t structures, but it's more generic now
Index: tests/Makefile
===================================================================
--- tests/Makefile	(revision 8c073a6e77edd56bc3d58d6b4af2a40f005aacad)
+++ tests/Makefile	(revision 7738014d6a9ad81806ddb4e06092791dbd10b616)
@@ -11,5 +11,5 @@
 main_objs = account.o bitlbee.o conf.o crypting.o help.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_xml.o storage_text.o user.o 
 
-test_objs = check.o check_util.o check_nick.o check_md5.o check_irc.o check_help.o check_user.o check_crypting.o
+test_objs = check.o check_util.o check_nick.o check_md5.o check_irc.o check_help.o check_user.o check_crypting.o check_set.o
 
 check: $(test_objs) $(addprefix ../, $(main_objs)) ../protocols/protocols.o ../lib/lib.o
Index: tests/check.c
===================================================================
--- tests/check.c	(revision 8c073a6e77edd56bc3d58d6b4af2a40f005aacad)
+++ tests/check.c	(revision 7738014d6a9ad81806ddb4e06092791dbd10b616)
@@ -60,4 +60,7 @@
 Suite *crypting_suite(void);
 
+/* From check_set.c */
+Suite *set_suite(void);
+
 int main (int argc, char **argv)
 {
@@ -103,4 +106,5 @@
 	srunner_add_suite(sr, user_suite());
 	srunner_add_suite(sr, crypting_suite());
+	srunner_add_suite(sr, set_suite());
 	if (no_fork)
 		srunner_set_fork_status(sr, CK_NOFORK);
Index: tests/check_set.c
===================================================================
--- tests/check_set.c	(revision 7738014d6a9ad81806ddb4e06092791dbd10b616)
+++ tests/check_set.c	(revision 7738014d6a9ad81806ddb4e06092791dbd10b616)
@@ -0,0 +1,130 @@
+#include <stdlib.h>
+#include <glib.h>
+#include <gmodule.h>
+#include <check.h>
+#include <string.h>
+#include "set.h"
+#include "testsuite.h"
+
+START_TEST(test_set_add)
+	void *data = "data";
+	set_t *s = NULL, *t;
+	t = set_add(&s, "name", "default", NULL, data);
+	fail_unless(s == t);
+	fail_unless(t->data == data);
+	fail_unless(strcmp(t->def, "default") == 0);
+END_TEST
+
+START_TEST(test_set_add_existing)
+	void *data = "data";
+	set_t *s = NULL, *t;
+	t = set_add(&s, "name", "default", NULL, data);
+	t = set_add(&s, "name", "newdefault", NULL, data);
+	fail_unless(s == t);
+	fail_unless(strcmp(t->def, "newdefault") == 0);
+END_TEST
+
+START_TEST(test_set_find_unknown)
+	set_t *s = NULL, *t;
+	fail_unless (set_find(&s, "foo") == NULL);
+END_TEST
+
+START_TEST(test_set_find)
+	void *data = "data";
+	set_t *s = NULL, *t;
+	t = set_add(&s, "name", "default", NULL, data);
+	fail_unless(s == t);
+	fail_unless(set_find(&s, "name") == t);
+END_TEST
+
+START_TEST(test_set_get_str_default)
+	void *data = "data";
+	set_t *s = NULL, *t;
+	t = set_add(&s, "name", "default", NULL, data);
+	fail_unless(s == t);
+	fail_unless(strcmp(set_getstr(&s, "name"), "default") == 0);
+END_TEST
+
+START_TEST(test_set_get_bool_default)
+	void *data = "data";
+	set_t *s = NULL, *t;
+	t = set_add(&s, "name", "true", NULL, data);
+	fail_unless(s == t);
+	fail_unless(set_getbool(&s, "name"));
+END_TEST
+
+START_TEST(test_set_get_bool_integer)
+	void *data = "data";
+	set_t *s = NULL, *t;
+	t = set_add(&s, "name", "3", NULL, data);
+	fail_unless(s == t);
+	fail_unless(set_getbool(&s, "name") == 3);
+END_TEST
+
+START_TEST(test_set_get_bool_unknown)
+	set_t *s = NULL;
+	fail_unless(set_getbool(&s, "name") == 0);
+END_TEST
+
+START_TEST(test_set_get_str_value)
+	void *data = "data";
+	set_t *s = NULL, *t;
+	t = set_add(&s, "name", "default", NULL, data);
+	set_setstr(&s, "name", "foo");
+	fail_unless(strcmp(set_getstr(&s, "name"), "foo") == 0);
+END_TEST
+
+START_TEST(test_set_get_str_unknown)
+	set_t *s = NULL;
+	fail_unless(set_getstr(&s, "name") == NULL);
+END_TEST
+
+START_TEST(test_setint)
+	void *data = "data";
+	set_t *s = NULL, *t;
+	t = set_add(&s, "name", "10", NULL, data);
+	set_setint(&s, "name", 3);
+	fail_unless(set_getint(&s, "name") == 3);
+END_TEST
+
+START_TEST(test_setstr)
+	void *data = "data";
+	set_t *s = NULL, *t;
+	t = set_add(&s, "name", "foo", NULL, data);
+	set_setstr(&s, "name", "bloe");
+	fail_unless(strcmp(set_getstr(&s, "name"), "bloe") == 0);
+END_TEST
+
+START_TEST(test_setstr_implicit)
+	void *data = "data";
+	set_t *s = NULL, *t;
+	set_setstr(&s, "name", "bloe");
+	fail_unless(set_find(&s, "name") != NULL);
+END_TEST
+
+START_TEST(test_set_get_int_unknown)
+	set_t *s = NULL;
+	fail_unless(set_getint(&s, "foo") == 0);
+END_TEST
+
+Suite *set_suite (void)
+{
+	Suite *s = suite_create("Set");
+	TCase *tc_core = tcase_create("Core");
+	suite_add_tcase (s, tc_core);
+	tcase_add_test (tc_core, test_set_add);
+	tcase_add_test (tc_core, test_set_add_existing);
+	tcase_add_test (tc_core, test_set_find_unknown);
+	tcase_add_test (tc_core, test_set_find);
+	tcase_add_test (tc_core, test_set_get_str_default);
+	tcase_add_test (tc_core, test_set_get_str_value);
+	tcase_add_test (tc_core, test_set_get_str_unknown);
+	tcase_add_test (tc_core, test_set_get_bool_default);
+	tcase_add_test (tc_core, test_set_get_bool_integer);
+	tcase_add_test (tc_core, test_set_get_bool_unknown);
+	tcase_add_test (tc_core, test_set_get_int_unknown);
+	tcase_add_test (tc_core, test_setint);
+	tcase_add_test (tc_core, test_setstr);
+	tcase_add_test (tc_core, test_setstr_implicit);
+	return s;
+}
Index: tests/testsuite.h
===================================================================
--- tests/testsuite.h	(revision 8c073a6e77edd56bc3d58d6b4af2a40f005aacad)
+++ tests/testsuite.h	(revision 7738014d6a9ad81806ddb4e06092791dbd10b616)
@@ -1,4 +1,6 @@
 #ifndef __BITLBEE_CHECK_H__
 #define __BITLBEE_CHECK_H__ 
+
+#include "irc.h"
 
 irc_t *torture_irc(void);
