cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=48dea342409fffcdd824b5d0ed00a180782b3459

commit 48dea342409fffcdd824b5d0ed00a180782b3459
Author: vivek <vivek.el...@samsung.com>
Date:   Wed Apr 22 15:37:32 2015 +0200

    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.el...@samsung.com>
    
    Reviewers: cedric
    
    Subscribers: cedric
    
    Differential Revision: https://phab.enlightenment.org/D2293
    
    Signed-off-by: Cedric BAIL <ced...@osg.samsung.com>
---
 src/Makefile_Eina.am           |  3 ++-
 src/tests/eina/eina_suite.c    |  1 +
 src/tests/eina/eina_suite.h    |  1 +
 src/tests/eina/eina_test_crc.c | 50 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/src/Makefile_Eina.am b/src/Makefile_Eina.am
index 160e7a9..6303510 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 6e16d8e..1a08480 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 433d95a..63d76cd 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 0000000..34a00f3
--- /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);
+}

-- 


Reply via email to