Index: tests/Makefile
===================================================================
--- tests/Makefile	(revision c2fa8279933a103d6576d891e85c1801d90c65ef)
+++ tests/Makefile	(revision 9b63df67847e72abb00246fdfc82830137153c3c)
@@ -6,5 +6,7 @@
 	./check
 
-check: check.o check_util.o ../util.o
+main_objs = account.o bitlbee.o conf.o crypting.o help.o ini.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_text.o url.o user.o util.o 
+
+check: check.o check_util.o check_nick.o $(addprefix ../, $(main_objs)) ../protocols/protocols.o
 	@echo '*' Linking $@
 	@$(CC) $(CFLAGS) -o $@ $^ $(LFLAGS) $(EFLAGS)
Index: tests/check.c
===================================================================
--- tests/check.c	(revision c2fa8279933a103d6576d891e85c1801d90c65ef)
+++ tests/check.c	(revision 9b63df67847e72abb00246fdfc82830137153c3c)
@@ -3,7 +3,21 @@
 #include <gmodule.h>
 #include <check.h>
+#include "bitlbee.h"
+
+global_t global;	/* Against global namespace pollution */
+
+double gettime()
+{
+	struct timeval time[1];
+
+	gettimeofday( time, 0 );
+	return( (double) time->tv_sec + (double) time->tv_usec / 1000000 );
+}
 
 /* From check_util.c */
 Suite *util_suite(void);
+
+/* From check_nick.c */
+Suite *nick_suite(void);
 
 int main (void)
@@ -11,4 +25,5 @@
 	int nf;
 	SRunner *sr = srunner_create(util_suite());
+	srunner_add_suite(sr, nick_suite());
 	srunner_run_all (sr, CK_NORMAL);
 	nf = srunner_ntests_failed(sr);
Index: tests/check_nick.c
===================================================================
--- tests/check_nick.c	(revision 9b63df67847e72abb00246fdfc82830137153c3c)
+++ tests/check_nick.c	(revision 9b63df67847e72abb00246fdfc82830137153c3c)
@@ -0,0 +1,70 @@
+#include <stdlib.h>
+#include <glib.h>
+#include <gmodule.h>
+#include <check.h>
+#include <string.h>
+#include "irc.h"
+#include "set.h"
+#include "util.h"
+
+START_TEST(test_nick_strip)
+{
+	int i;
+	const char *get[] = { "test:", "test", "test\n", 
+		"thisisaveryveryveryverylongnick", 
+		"thisisave:ryveryveryverylongnick",
+		"t::::est",
+		NULL };
+	const char *expected[] = { "test", "test", "test", 
+		"thisisaveryveryveryveryl", 
+		"thisisaveryveryveryveryl", 
+		"test",
+		NULL };
+
+	for (i = 0; get[i]; i++) {
+		char copy[30];
+		strcpy(copy, get[i]);
+		nick_strip(copy);
+		fail_unless (strcmp(copy, expected[i]) == 0, 
+					 "(%d) nick_strip broken: %s -> %s (expected: %s)", 
+					 i, get[i], copy, expected[i]);
+	}
+}
+END_TEST
+
+START_TEST(test_nick_ok_ok)
+{
+	const char *nicks[] = { "foo", "bar", "bla[", "blie]", 
+		                    "BreEZaH", "\\od^~", NULL };
+	int i;
+
+	for (i = 0; nicks[i]; i++) {
+		fail_unless (nick_ok(nicks[i]) == 1,
+					 "nick_ok() failed: %s", nicks[i]);
+	}
+}
+END_TEST
+
+START_TEST(test_nick_ok_notok)
+{
+	const char *nicks[] = { "thisisaveryveryveryveryveryveryverylongnick",
+		                    "\nillegalchar", "", "nick%", NULL };
+	int i;
+
+	for (i = 0; nicks[i]; i++) {
+		fail_unless (nick_ok(nicks[i]) == 0,
+					 "nick_ok() succeeded for invalid: %s", nicks[i]);
+	}
+}
+END_TEST
+
+Suite *nick_suite (void)
+{
+	Suite *s = suite_create("Nick");
+	TCase *tc_core = tcase_create("Core");
+	suite_add_tcase (s, tc_core);
+	tcase_add_test (tc_core, test_nick_ok_ok);
+	tcase_add_test (tc_core, test_nick_ok_notok);
+	tcase_add_test (tc_core, test_nick_strip);
+	return s;
+}
Index: tests/check_util.c
===================================================================
--- tests/check_util.c	(revision c2fa8279933a103d6576d891e85c1801d90c65ef)
+++ tests/check_util.c	(revision 9b63df67847e72abb00246fdfc82830137153c3c)
@@ -25,4 +25,22 @@
 END_TEST
 
+START_TEST(test_strip_newlines)
+{
+	int i;
+	const char *get[] = { "Test", "Test\r\n", "Test\nX\n", NULL };
+	const char *expected[] = { "Test", "Test  ", "Test X ", NULL };
+
+	for (i = 0; get[i]; i++) {
+		char copy[20], *ret;
+		strcpy(copy, get[i]);
+		ret = strip_newlines(copy);
+		fail_unless (strcmp(copy, expected[i]) == 0, 
+					 "(%d) strip_newlines broken: %s -> %s (expected: %s)", 
+					 i, get[i], copy, expected[i]);
+		fail_unless (copy == ret, "Original string not returned"); 
+	}
+}
+END_TEST
+
 Suite *util_suite (void)
 {
@@ -31,4 +49,5 @@
 	suite_add_tcase (s, tc_core);
 	tcase_add_test (tc_core, test_strip_linefeed);
+	tcase_add_test (tc_core, test_strip_newlines);
 	return s;
 }
