[tracker] tests/libtracker-common: tests for crc32 calculation



commit 062c6b114ab9a3a3ce65db72076fff5ea85698f4
Author: Ivan Frade <ivan frade gmail com>
Date:   Fri Oct 28 16:45:50 2011 +0300

    tests/libtracker-common: tests for crc32 calculation

 tests/libtracker-common/Makefile.am          |    5 ++-
 tests/libtracker-common/tracker-crc32-test.c |   46 ++++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 1 deletions(-)
---
diff --git a/tests/libtracker-common/Makefile.am b/tests/libtracker-common/Makefile.am
index e3a66a5..53ac169 100644
--- a/tests/libtracker-common/Makefile.am
+++ b/tests/libtracker-common/Makefile.am
@@ -8,7 +8,8 @@ TEST_PROGS +=                                          \
 	tracker-file-utils                             \
 	tracker-utils				       \
 	tracker-albumart-test			       \
-	tracker-sched-test
+	tracker-sched-test			       \
+	tracker-crc32-test
 
 AM_CPPFLAGS =                                      \
 	-DTOP_SRCDIR=\"$(abs_top_srcdir)\"             \
@@ -37,4 +38,6 @@ tracker_albumart_test_SOURCES = tracker-albumart-test.c
 
 tracker_sched_test_SOURCES = tracker-sched-test.c
 
+tracker_crc32_test_SOURCES = tracker-crc32-test.c
+
 EXTRA_DIST = non-utf8.txt
diff --git a/tests/libtracker-common/tracker-crc32-test.c b/tests/libtracker-common/tracker-crc32-test.c
new file mode 100644
index 0000000..a583c21
--- /dev/null
+++ b/tests/libtracker-common/tracker-crc32-test.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2011, Nokia <ivan frade nokia com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ */
+#include <glib.h>
+#include <glib-object.h>
+
+#include <libtracker-common/tracker-crc32.h>
+
+// Using http://crc32-checksum.waraxe.us/ to check the result
+static void
+test_crc32_calculate ()
+{
+        guint32 result;
+        guint32 expected = 0x81F8B2A3;
+
+        result = tracker_crc32 ("Who is Meego? Meego is dead, baby. Meego is dead", 48);
+        
+        g_assert_cmpint (expected, ==, result);
+}
+
+gint
+main (gint argc, gchar **argv)
+{
+        g_type_init ();
+        g_test_init (&argc, &argv, NULL);
+
+        g_test_add_func ("/libtracker-common/crc32/calculate",
+                         test_crc32_calculate);
+
+        return g_test_run ();
+}



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