From: <fac...@us...> - 2006-11-26 22:03:28
|
Revision: 17823 http://svn.sourceforge.net/gaim/?rev=17823&view=rev Author: faceprint Date: 2006-11-26 14:03:23 -0800 (Sun, 26 Nov 2006) Log Message: ----------- baby steps: 4 unit tests for libgaim to run these, you'll need check (http://check.sf.net/) 0.9.4 or later installed they run when you run 'make check' Modified Paths: -------------- trunk/configure.ac trunk/libgaim/Makefile.am Added Paths: ----------- trunk/libgaim/tests/ trunk/libgaim/tests/Makefile.am trunk/libgaim/tests/check_libgaim.c Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-11-26 20:45:29 UTC (rev 17822) +++ trunk/configure.ac 2006-11-26 22:03:23 UTC (rev 17823) @@ -1807,6 +1807,14 @@ fi dnl ####################################################################### +dnl # Check for check +dnl ####################################################################### +PKG_CHECK_MODULES(CHECK, check >= 0.9.4, have_check=yes, have_check=no) +AM_CONDITIONAL(HAVE_CHECK, test "x$have_check" = "xyes") +AC_SUBST(CHECK_CFLAGS) +AC_SUBST(CHECK_LIBS) + +dnl ####################################################################### dnl # Check for Doxygen and dot (part of GraphViz) dnl ####################################################################### AC_ARG_ENABLE(doxygen, @@ -1906,6 +1914,7 @@ libgaim/protocols/toc/Makefile libgaim/protocols/yahoo/Makefile libgaim/protocols/zephyr/Makefile + libgaim/tests/Makefile console/Makefile console/libgnt/Makefile console/libgnt/gnt.pc Modified: trunk/libgaim/Makefile.am =================================================================== --- trunk/libgaim/Makefile.am 2006-11-26 20:45:29 UTC (rev 17822) +++ trunk/libgaim/Makefile.am 2006-11-26 22:03:23 UTC (rev 17823) @@ -23,7 +23,7 @@ GCONF_DIR=gconf endif -SUBDIRS = $(GCONF_DIR) plugins protocols +SUBDIRS = $(GCONF_DIR) plugins protocols tests gaim_coresources = \ account.c \ Added: trunk/libgaim/tests/Makefile.am =================================================================== --- trunk/libgaim/tests/Makefile.am (rev 0) +++ trunk/libgaim/tests/Makefile.am 2006-11-26 22:03:23 UTC (rev 17823) @@ -0,0 +1,7 @@ +if HAVE_CHECK +TESTS = check_libgaim +check_PROGRAMS = check_libgaim +check_libgaim_SOURCES = check_libgaim.c $(top_builddir)/libgaim/gaim.h +check_libgaim_CFLAGS = @CHECK_CFLAGS@ $(GLIB_CFLAGS) +check_libgaim_LDADD = @CHECK_LIBS@ $(GLIB_LIBS) $(top_builddir)/libgaim/libgaim.la +endif Property changes on: trunk/libgaim/tests/Makefile.am ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native Added: trunk/libgaim/tests/check_libgaim.c =================================================================== --- trunk/libgaim/tests/check_libgaim.c (rev 0) +++ trunk/libgaim/tests/check_libgaim.c 2006-11-26 22:03:23 UTC (rev 17823) @@ -0,0 +1,69 @@ +#include <glib.h> +#include <check.h> +#include <stdlib.h> +#include "../util.h" + +START_TEST(test_util_base16_encode) +{ + gchar *out = gaim_base16_encode("hello, world!", 14); + fail_unless(strcmp("68656c6c6f2c20776f726c642100", out) == 0, NULL); + g_free(out); +} +END_TEST + +START_TEST(test_util_base16_decode) +{ + gsize sz = 0; + guchar *out = gaim_base16_decode("21646c726f77202c6f6c6c656800", &sz); + fail_unless(sz == 14, NULL); + fail_unless(strcmp("!dlrow ,olleh", out) == 0, NULL); + g_free(out); +} +END_TEST + +START_TEST(test_util_base64_encode) +{ + gchar *out = gaim_base64_encode("forty-two", 10); + fail_unless(strcmp("Zm9ydHktdHdvAA==",out) == 0, NULL); + g_free(out); +} +END_TEST + +START_TEST(test_util_base64_decode) +{ + gsize sz; + guchar *out = gaim_base64_decode("b3d0LXl0cm9mAA==", &sz); + fail_unless(sz == 10, NULL); + fail_unless(strcmp("owt-ytrof", out) == 0, NULL); + g_free(out); +} +END_TEST + +Suite * +util_suite(void) +{ + Suite *s = suite_create("Utility Functions"); + + TCase *tc = tcase_create("Base16"); + tcase_add_test(tc, test_util_base16_encode); + tcase_add_test(tc, test_util_base16_decode); + suite_add_tcase(s, tc); + + tc = tcase_create("Base64"); + tcase_add_test(tc, test_util_base64_encode); + tcase_add_test(tc, test_util_base64_decode); + suite_add_tcase(s, tc); + + return s; +} + +int main(void) +{ + int number_failed; + Suite *s = util_suite (); + SRunner *sr = srunner_create (s); + srunner_run_all (sr, CK_NORMAL); + number_failed = srunner_ntests_failed (sr); + srunner_free (sr); + return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} Property changes on: trunk/libgaim/tests/check_libgaim.c ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |