summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvivek <vivek.ellur@samsung.com>2015-04-22 15:37:32 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-05-07 09:53:09 +0200
commit48dea342409fffcdd824b5d0ed00a180782b3459 (patch)
treec797eacab24f7fcb19f4294ff210107d42b07c65
parenta2f2d942c6e49e74990a0c56d38de343cf42d696 (diff)
downloadefl-48dea342409fffcdd824b5d0ed00a180782b3459.tar.gz
eina: add test case for eina_crc function in eina module.
Summary: I added test cases using seed 0xffffffff, I was not able to get crc value for different seeds online. Checked some of the links, but they are using entirely different logic and value was not matching for other seed value. Signed-off-by: vivek <vivek.ellur@samsung.com> Reviewers: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2293 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/Makefile_Eina.am3
-rw-r--r--src/tests/eina/eina_suite.c1
-rw-r--r--src/tests/eina/eina_suite.h1
-rw-r--r--src/tests/eina/eina_test_crc.c50
4 files changed, 54 insertions, 1 deletions
diff --git a/src/Makefile_Eina.am b/src/Makefile_Eina.am
index 160e7a9054..6303510172 100644
--- a/src/Makefile_Eina.am
+++ b/src/Makefile_Eina.am
@@ -285,7 +285,8 @@ tests/eina/eina_test_barrier.c \
tests/eina/eina_test_tmpstr.c \
tests/eina/eina_test_trash.c \
tests/eina/eina_test_lock.c \
-tests/eina/eina_test_xattr.c
+tests/eina/eina_test_xattr.c \
+tests/eina/eina_test_crc.c
# tests/eina/eina_test_model.c
diff --git a/src/tests/eina/eina_suite.c b/src/tests/eina/eina_suite.c
index 6e16d8ecb8..1a08480f7f 100644
--- a/src/tests/eina/eina_suite.c
+++ b/src/tests/eina/eina_suite.c
@@ -79,6 +79,7 @@ static const Eina_Test_Case etc[] = {
#ifdef XATTR_TEST_DIR
{ "Xattr", eina_test_xattr },
#endif
+ {"Crc", eina_test_crc },
{ NULL, NULL }
};
diff --git a/src/tests/eina/eina_suite.h b/src/tests/eina/eina_suite.h
index 433d95a6e3..63d76cdce1 100644
--- a/src/tests/eina/eina_suite.h
+++ b/src/tests/eina/eina_suite.h
@@ -64,5 +64,6 @@ void eina_test_locking(TCase *tc);
void eina_test_abi(TCase *tc);
void eina_test_trash(TCase *tc);
void eina_test_xattr(TCase *tc);
+void eina_test_crc(TCase *tc);
#endif /* EINA_SUITE_H_ */
diff --git a/src/tests/eina/eina_test_crc.c b/src/tests/eina/eina_test_crc.c
new file mode 100644
index 0000000000..34a00f31b1
--- /dev/null
+++ b/src/tests/eina/eina_test_crc.c
@@ -0,0 +1,50 @@
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "eina_suite.h"
+#include "Eina.h"
+
+START_TEST(eina_crc_simple)
+{
+ unsigned int seed = 0xffffffff, i, ret;
+ const char *data[] =
+ {
+ "Hello World",
+ "This is to test crc",
+ "4baAsru=A$r&e.-",
+ "=-.^Y@~Lp5e1)b^",
+ "J(uhX4)!&Q#2,jr"
+ };
+
+ unsigned int result[] =
+ {
+ 0x4a17b156,
+ 0x738bec38,
+ 0xcd56f3c6,
+ 0x9732147f,
+ 0x12c660a3
+ };
+ const char *s1 = "Hello ";
+ const char *s2 = "World";
+
+ for (i = 0; i < sizeof(data) / sizeof(data[0]); ++i)
+ {
+ ret = eina_crc(data[i], strlen(data[i]), seed, EINA_TRUE);
+ fail_if(ret != result[i]);
+ }
+
+ ret = eina_crc(s1, strlen(s1), 0xffffffff, EINA_TRUE);
+ ret = eina_crc(s2, strlen(s2), ret, EINA_FALSE);
+ fail_if(ret != result[0]);
+}
+END_TEST
+
+void eina_test_crc(TCase *tc)
+{
+ tcase_add_test(tc, eina_crc_simple);
+}