[libdmapsharing] Add unit test of MD5 code Signed-off-by: W. Michael Petullo <mike flyn org>



commit 1c65e0fda97c1ca176e7fa47fa51ba8ee3261386
Author: W. Michael Petullo <mike flyn org>
Date:   Tue May 24 10:49:25 2011 -0500

    Add unit test of MD5 code
    Signed-off-by: W. Michael Petullo <mike flyn org>

 libdmapsharing/daap-connection.c |    2 +-
 libdmapsharing/dmap-md5.c        |   23 +++++++++++++++++++++++
 libdmapsharing/dmap-md5.h        |    6 ++++++
 tests/unit-test.c                |    3 ++-
 4 files changed, 32 insertions(+), 2 deletions(-)
---
diff --git a/libdmapsharing/daap-connection.c b/libdmapsharing/daap-connection.c
index 750b5f8..ac85199 100644
--- a/libdmapsharing/daap-connection.c
+++ b/libdmapsharing/daap-connection.c
@@ -210,7 +210,7 @@ END_TEST
 Suite *dmap_test_daap_connection_suite (void)
 {
 	TCase *tc;
-	Suite *s = suite_create("dmap_test_daap_connection_suite");
+	Suite *s = suite_create("test_daap_connection_suite");
 
 	tc = tcase_create("test_get_protocol_version_cc");
 	tcase_add_test(tc, test_get_protocol_version_cc);
diff --git a/libdmapsharing/dmap-md5.c b/libdmapsharing/dmap-md5.c
index ec5363c..48954d1 100644
--- a/libdmapsharing/dmap-md5.c
+++ b/libdmapsharing/dmap-md5.c
@@ -485,3 +485,26 @@ dmap_hash_generate (short version_major,
 
 	return;
 }
+
+#ifdef HAVE_CHECK
+START_TEST(test_dmap_hash_generate_v3_h2)
+{
+	char hash[33] = { 0 };
+	char *url = "test://foo";
+	dmap_hash_generate (3, url, 2, hash, 0);
+	fail_unless (! strcmp (hash, "798A9D80B6F08E339603BE83E0FEAD03"));
+}
+END_TEST
+
+Suite *dmap_test_dmap_md5_suite (void)
+{
+	TCase *tc;
+	Suite *s = suite_create("test_dmap_hash_generate");
+
+	tc = tcase_create("test_dmap_hash_generate_v3_h2");
+	tcase_add_test(tc, test_dmap_hash_generate_v3_h2);
+	suite_add_tcase(s, tc);
+
+	return s;
+}
+#endif
diff --git a/libdmapsharing/dmap-md5.h b/libdmapsharing/dmap-md5.h
index 8e12862..8209106 100644
--- a/libdmapsharing/dmap-md5.h
+++ b/libdmapsharing/dmap-md5.h
@@ -29,5 +29,11 @@ G_BEGIN_DECLS
 				 guchar hash_select,
 				 guchar * out, gint request_id);
 
+#ifdef HAVE_CHECK
+#include <check.h>
+
+Suite *dmap_test_daap_connection_suite (void);
+#endif
+
 G_END_DECLS
 #endif
diff --git a/tests/unit-test.c b/tests/unit-test.c
index 1e65aae..afb1b09 100644
--- a/tests/unit-test.c
+++ b/tests/unit-test.c
@@ -52,7 +52,8 @@ int main(void)
 	g_log_set_handler ("libdmapsharing", G_LOG_LEVEL_DEBUG, debug_null, NULL);
 	g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, debug_null, NULL);
 
-	run_suite (dmap_test_daap_connection_suite());
+	run_suite (dmap_test_daap_connection_suite ());
+	run_suite (dmap_test_dmap_md5_suite ());
 
 	exit (EXIT_SUCCESS);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]