diff options
author | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
commit | dd7595a3475407a7fa96a97393bae8c5220e8762 (patch) | |
tree | e341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/eina/src/tests/eina_test_str.c | |
parent | Add the skeleton. (diff) | |
download | SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.zip SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.gz SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.bz2 SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.xz |
Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje.
Note that embryo wont be used, but I'm not sure yet if you can build edje without it.
Diffstat (limited to 'libraries/eina/src/tests/eina_test_str.c')
-rw-r--r-- | libraries/eina/src/tests/eina_test_str.c | 181 |
1 files changed, 181 insertions, 0 deletions
diff --git a/libraries/eina/src/tests/eina_test_str.c b/libraries/eina/src/tests/eina_test_str.c new file mode 100644 index 0000000..f0ea291 --- /dev/null +++ b/libraries/eina/src/tests/eina_test_str.c | |||
@@ -0,0 +1,181 @@ | |||
1 | /* EINA - EFL data type library | ||
2 | * Copyright (C) 2010 Gustavo Sverzut Barbieri | ||
3 | * | ||
4 | * This library is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU Lesser General Public | ||
6 | * License as published by the Free Software Foundation; either | ||
7 | * version 2.1 of the License, or (at your option) any later version. | ||
8 | * | ||
9 | * This library is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | * Lesser General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU Lesser General Public | ||
15 | * License along with this library; | ||
16 | * if not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #ifdef HAVE_CONFIG_H | ||
20 | # include "config.h" | ||
21 | #endif | ||
22 | |||
23 | #include <stdio.h> | ||
24 | |||
25 | #include "eina_suite.h" | ||
26 | #include "Eina.h" | ||
27 | |||
28 | START_TEST(str_simple) | ||
29 | { | ||
30 | eina_init(); | ||
31 | |||
32 | fail_if(!eina_str_has_prefix("", "")); | ||
33 | |||
34 | fail_if(!eina_str_has_prefix("x", "x")); | ||
35 | fail_if(!eina_str_has_prefix("xab", "x")); | ||
36 | fail_if(!eina_str_has_prefix("xab", "xab")); | ||
37 | |||
38 | fail_if(eina_str_has_prefix("x", "xab")); | ||
39 | fail_if(eina_str_has_prefix("xab", "xyz")); | ||
40 | fail_if(eina_str_has_prefix("", "x")); | ||
41 | fail_if(eina_str_has_prefix("X", "x")); | ||
42 | fail_if(eina_str_has_prefix("xAb", "X")); | ||
43 | fail_if(eina_str_has_prefix("xAb", "xab")); | ||
44 | |||
45 | |||
46 | fail_if(!eina_str_has_suffix("", "")); | ||
47 | |||
48 | fail_if(!eina_str_has_suffix("x", "x")); | ||
49 | fail_if(!eina_str_has_suffix("abx", "x")); | ||
50 | fail_if(!eina_str_has_suffix("xab", "xab")); | ||
51 | |||
52 | fail_if(eina_str_has_suffix("x", "xab")); | ||
53 | fail_if(eina_str_has_suffix("xab", "xyz")); | ||
54 | fail_if(eina_str_has_suffix("", "x")); | ||
55 | fail_if(eina_str_has_suffix("X", "x")); | ||
56 | fail_if(eina_str_has_suffix("aBx", "X")); | ||
57 | fail_if(eina_str_has_suffix("xaB", "Xab")); | ||
58 | |||
59 | |||
60 | fail_if(!eina_str_has_extension("", "")); | ||
61 | |||
62 | fail_if(!eina_str_has_extension("x", "x")); | ||
63 | fail_if(!eina_str_has_extension("abx", "x")); | ||
64 | fail_if(!eina_str_has_extension("xab", "xab")); | ||
65 | fail_if(!eina_str_has_extension("x", "X")); | ||
66 | fail_if(!eina_str_has_extension("abx", "X")); | ||
67 | fail_if(!eina_str_has_extension("xab", "Xab")); | ||
68 | fail_if(!eina_str_has_extension("X", "X")); | ||
69 | fail_if(!eina_str_has_extension("aBx", "X")); | ||
70 | fail_if(!eina_str_has_extension("xaB", "Xab")); | ||
71 | |||
72 | fail_if(eina_str_has_extension("x", "xab")); | ||
73 | fail_if(eina_str_has_extension("xab", "xyz")); | ||
74 | fail_if(eina_str_has_extension("", "x")); | ||
75 | fail_if(eina_str_has_extension("x", "xAb")); | ||
76 | fail_if(eina_str_has_extension("xab", "xYz")); | ||
77 | fail_if(eina_str_has_extension("", "x")); | ||
78 | |||
79 | fail_if(eina_strlen_bounded("abc", 1024) != strlen("abc")); | ||
80 | fail_if(eina_strlen_bounded("abc", 2) != (size_t)-1); | ||
81 | |||
82 | eina_shutdown(); | ||
83 | } | ||
84 | END_TEST | ||
85 | |||
86 | START_TEST(str_split) | ||
87 | { | ||
88 | char **result; | ||
89 | unsigned int elements; | ||
90 | |||
91 | eina_init(); | ||
92 | |||
93 | result = eina_str_split_full("nomatch", "", -1, &elements); | ||
94 | fail_if(result != NULL); | ||
95 | fail_if(elements != 0); | ||
96 | |||
97 | result = eina_str_split_full("nomatch", "x", -1, &elements); | ||
98 | fail_if(result == NULL); | ||
99 | fail_if(elements != 1); | ||
100 | fail_if(strcmp(result[0], "nomatch") != 0); | ||
101 | free(result[0]); | ||
102 | free(result); | ||
103 | |||
104 | result = eina_str_split_full("nomatch", "xyz", -1, &elements); | ||
105 | fail_if(result == NULL); | ||
106 | fail_if(elements != 1); | ||
107 | fail_if(strcmp(result[0], "nomatch") != 0); | ||
108 | free(result[0]); | ||
109 | free(result); | ||
110 | |||
111 | result = eina_str_split_full("match:match:match", ":", -1, &elements); | ||
112 | fail_if(result == NULL); | ||
113 | fail_if(elements != 3); | ||
114 | while (elements >= 1) | ||
115 | { | ||
116 | elements--; | ||
117 | fail_if(strcmp(result[elements], "match") != 0); | ||
118 | } | ||
119 | free(result[0]); | ||
120 | free(result); | ||
121 | |||
122 | result = eina_str_split_full("a:b:c", ":", -1, &elements); | ||
123 | fail_if(result == NULL); | ||
124 | fail_if(elements != 3); | ||
125 | fail_if(strcmp(result[0], "a") != 0); | ||
126 | fail_if(strcmp(result[1], "b") != 0); | ||
127 | fail_if(strcmp(result[2], "c") != 0); | ||
128 | free(result[0]); | ||
129 | free(result); | ||
130 | |||
131 | result = eina_str_split_full("a:b:", ":", -1, &elements); | ||
132 | fail_if(result == NULL); | ||
133 | fail_if(elements != 3); | ||
134 | fail_if(strcmp(result[0], "a") != 0); | ||
135 | fail_if(strcmp(result[1], "b") != 0); | ||
136 | fail_if(strcmp(result[2], "") != 0); | ||
137 | free(result[0]); | ||
138 | free(result); | ||
139 | |||
140 | result = eina_str_split_full(":b:c", ":", -1, &elements); | ||
141 | fail_if(result == NULL); | ||
142 | fail_if(elements != 3); | ||
143 | fail_if(strcmp(result[0], "") != 0); | ||
144 | fail_if(strcmp(result[1], "b") != 0); | ||
145 | fail_if(strcmp(result[2], "c") != 0); | ||
146 | free(result[0]); | ||
147 | free(result); | ||
148 | |||
149 | result = eina_str_split_full(":", ":", -1, &elements); | ||
150 | fail_if(result == NULL); | ||
151 | fail_if(elements != 2); | ||
152 | fail_if(strcmp(result[0], "") != 0); | ||
153 | fail_if(strcmp(result[1], "") != 0); | ||
154 | free(result[0]); | ||
155 | free(result); | ||
156 | |||
157 | result = eina_str_split_full("a", "!!!!!!!!!", -1, &elements); | ||
158 | fail_if(result == NULL); | ||
159 | fail_if(elements != 1); | ||
160 | fail_if(strcmp(result[0], "a") != 0); | ||
161 | free(result[0]); | ||
162 | free(result); | ||
163 | |||
164 | result = eina_str_split_full("aaba", "ab", -1, &elements); | ||
165 | fail_if(result == NULL); | ||
166 | fail_if(elements != 2); | ||
167 | fail_if(strcmp(result[0], "a") != 0); | ||
168 | fail_if(strcmp(result[1], "a") != 0); | ||
169 | free(result[0]); | ||
170 | free(result); | ||
171 | |||
172 | eina_shutdown(); | ||
173 | } | ||
174 | END_TEST | ||
175 | |||
176 | void | ||
177 | eina_test_str(TCase *tc) | ||
178 | { | ||
179 | tcase_add_test(tc, str_simple); | ||
180 | tcase_add_test(tc, str_split); | ||
181 | } | ||