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)
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 160e7a9..6303510 100644
--- a/src/Makefile_Eina.am
+++ b/src/Makefile_Eina.am
@@ -285,7 +285,8 @@ tests/eina/eina_test_barrier.c \
285tests/eina/eina_test_tmpstr.c \ 285tests/eina/eina_test_tmpstr.c \
286tests/eina/eina_test_trash.c \ 286tests/eina/eina_test_trash.c \
287tests/eina/eina_test_lock.c \ 287tests/eina/eina_test_lock.c \
288tests/eina/eina_test_xattr.c 288tests/eina/eina_test_xattr.c \
289tests/eina/eina_test_crc.c
289# tests/eina/eina_test_model.c 290# tests/eina/eina_test_model.c
290 291
291 292
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[] = {
79#ifdef XATTR_TEST_DIR 79#ifdef XATTR_TEST_DIR
80 { "Xattr", eina_test_xattr }, 80 { "Xattr", eina_test_xattr },
81#endif 81#endif
82 {"Crc", eina_test_crc },
82 { NULL, NULL } 83 { NULL, NULL }
83}; 84};
84 85
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);
64void eina_test_abi(TCase *tc); 64void eina_test_abi(TCase *tc);
65void eina_test_trash(TCase *tc); 65void eina_test_trash(TCase *tc);
66void eina_test_xattr(TCase *tc); 66void eina_test_xattr(TCase *tc);
67void eina_test_crc(TCase *tc);
67 68
68#endif /* EINA_SUITE_H_ */ 69#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 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <stdlib.h>
6#include <stdio.h>
7#include <string.h>
8
9#include "eina_suite.h"
10#include "Eina.h"
11
12START_TEST(eina_crc_simple)
13{
14 unsigned int seed = 0xffffffff, i, ret;
15 const char *data[] =
16 {
17 "Hello World",
18 "This is to test crc",
19 "4baAsru=A$r&e.-",
20 "=-.^Y@~Lp5e1)b^",
21 "J(uhX4)!&Q#2,jr"
22 };
23
24 unsigned int result[] =
25 {
26 0x4a17b156,
27 0x738bec38,
28 0xcd56f3c6,
29 0x9732147f,
30 0x12c660a3
31 };
32 const char *s1 = "Hello ";
33 const char *s2 = "World";
34
35 for (i = 0; i < sizeof(data) / sizeof(data[0]); ++i)
36 {
37 ret = eina_crc(data[i], strlen(data[i]), seed, EINA_TRUE);
38 fail_if(ret != result[i]);
39 }
40
41 ret = eina_crc(s1, strlen(s1), 0xffffffff, EINA_TRUE);
42 ret = eina_crc(s2, strlen(s2), ret, EINA_FALSE);
43 fail_if(ret != result[0]);
44}
45END_TEST
46
47void eina_test_crc(TCase *tc)
48{
49 tcase_add_test(tc, eina_crc_simple);
50}