summaryrefslogtreecommitdiff
path: root/src/tests/eet
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-12-15 15:18:41 -0800
committerCedric BAIL <cedric@osg.samsung.com>2016-12-15 15:18:41 -0800
commit20d77fda989b360e25e1ad3b5a5bdb78fd3ab67d (patch)
treec6563a2d91e4fd66056faf3f623ffa72ea613fc0 /src/tests/eet
parent0ff7bf3611d3769d2da0bc2521586dc285d5765e (diff)
eet: add test for eet_memopen_read.
Diffstat (limited to 'src/tests/eet')
-rw-r--r--src/tests/eet/eet_test_file.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/tests/eet/eet_test_file.c b/src/tests/eet/eet_test_file.c
index 2c9efb6cb4..f7926f7e61 100644
--- a/src/tests/eet/eet_test_file.c
+++ b/src/tests/eet/eet_test_file.c
@@ -14,9 +14,13 @@
14START_TEST(eet_test_file_simple_write) 14START_TEST(eet_test_file_simple_write)
15{ 15{
16 const char *buffer = "Here is a string of data to save !"; 16 const char *buffer = "Here is a string of data to save !";
17 Eina_Iterator *it;
18 Eina_File *f;
19 Eet_Entry *entry;
17 Eet_File *ef; 20 Eet_File *ef;
18 char *test; 21 char *test;
19 char *file; 22 char *file;
23 void *m;
20 int size; 24 int size;
21 int tmpfd; 25 int tmpfd;
22 26
@@ -43,6 +47,43 @@ START_TEST(eet_test_file_simple_write)
43 47
44 eet_close(ef); 48 eet_close(ef);
45 49
50 /* Test read from buffer */
51 f = eina_file_open(file, EINA_FALSE);
52 fail_if(!f);
53
54 m = eina_file_map_all(f, EINA_FILE_WILLNEED);
55 fail_if(!m);
56
57 ef = eet_memopen_read(m, eina_file_size_get(f));
58 fail_if(!ef);
59
60 test = eet_read(ef, "keys/tests", &size);
61 fail_if(!test);
62 fail_if(size != (int)strlen(buffer) + 1);
63
64 fail_if(memcmp(test, buffer, strlen(buffer) + 1) != 0);
65
66 test = eet_read(ef, "keys/alias2", &size);
67 fail_if(!test);
68 fail_if(size != (int)strlen(buffer) + 1);
69
70 fail_if(eet_read_direct(ef, "key/alias2", &size));
71
72 fail_if(eet_mode_get(ef) != EET_FILE_MODE_READ);
73 fail_if(eet_num_entries(ef) != 3);
74
75 it = eet_list_entries(ef);
76 fail_if(!it);
77 EINA_ITERATOR_FOREACH(it, entry)
78 fail_if(strcmp(entry->name, "keys/tests") &&
79 strcmp(entry->name, "keys/alias") &&
80 strcmp(entry->name, "keys/alias2"));
81
82 eet_close(ef);
83
84 eina_file_map_free(f, m);
85 eina_file_close(f);
86
46 /* Test read of simple file */ 87 /* Test read of simple file */
47 ef = eet_open(file, EET_FILE_MODE_READ); 88 ef = eet_open(file, EET_FILE_MODE_READ);
48 fail_if(!ef); 89 fail_if(!ef);