aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/eina/src/tests/eina_test_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/eina/src/tests/eina_test_file.c')
-rw-r--r--libraries/eina/src/tests/eina_test_file.c142
1 files changed, 0 insertions, 142 deletions
diff --git a/libraries/eina/src/tests/eina_test_file.c b/libraries/eina/src/tests/eina_test_file.c
deleted file mode 100644
index a3ba998..0000000
--- a/libraries/eina/src/tests/eina_test_file.c
+++ /dev/null
@@ -1,142 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
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 <stdlib.h>
24#include <stdio.h>
25#include <string.h>
26
27#include "eina_suite.h"
28#include "Eina.h"
29#include "eina_safety_checks.h"
30
31#ifdef EINA_SAFETY_CHECKS
32struct log_ctx {
33 const char *msg;
34 const char *fnc;
35 Eina_Bool did;
36};
37
38/* tests should not output on success, just uncomment this for debugging */
39//#define SHOW_LOG 1
40
41static void
42_eina_test_safety_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args __UNUSED__)
43{
44 struct log_ctx *ctx = data;
45 va_list cp_args;
46 const char *str;
47
48 va_copy(cp_args, args);
49 str = va_arg(cp_args, const char *);
50 va_end(cp_args);
51
52 ck_assert_int_eq(level, EINA_LOG_LEVEL_ERR);
53 ck_assert_str_eq(fmt, "%s");
54 ck_assert_str_eq(ctx->msg, str);
55 ck_assert_str_eq(ctx->fnc, fnc);
56 ctx->did = EINA_TRUE;
57
58#ifdef SHOW_LOG
59 eina_log_print_cb_stderr(d, level, file, fnc, line, fmt, NULL, args);
60#else
61 (void)d;
62 (void)file;
63 (void)line;
64#endif
65}
66#endif
67
68
69START_TEST(eina_file_split_simple)
70{
71 Eina_Array *ea;
72
73 eina_init();
74
75#ifdef EINA_SAFETY_CHECKS
76#ifdef SHOW_LOG
77 fprintf(stderr, "you should have a safety check failure below:\n");
78#endif
79 struct log_ctx ctx;
80
81#define TEST_MAGIC_SAFETY(fn, _msg) \
82 ctx.msg = _msg; \
83 ctx.fnc = fn; \
84 ctx.did = EINA_FALSE
85
86 eina_log_print_cb_set(_eina_test_safety_print_cb, &ctx);
87
88 TEST_MAGIC_SAFETY("eina_file_split", "safety check failed: path == NULL");
89 ea = eina_file_split(NULL);
90 fail_if(ea);
91 fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED);
92 fail_unless(ctx.did);
93
94 eina_log_print_cb_set(eina_log_print_cb_stderr, NULL);
95#undef TEST_MAGIC_SAFETY
96#endif
97
98#ifdef _WIN32
99 ea = eina_file_split(strdup("\\this\\is\\a\\small\\test"));
100#else
101 ea = eina_file_split(strdup("/this/is/a/small/test"));
102#endif
103
104 fail_if(!ea);
105 fail_if(eina_array_count(ea) != 5);
106 fail_if(strcmp(eina_array_data_get(ea, 0), "this"));
107 fail_if(strcmp(eina_array_data_get(ea, 1), "is"));
108 fail_if(strcmp(eina_array_data_get(ea, 2), "a"));
109 fail_if(strcmp(eina_array_data_get(ea, 3), "small"));
110 fail_if(strcmp(eina_array_data_get(ea, 4), "test"));
111
112 eina_array_free(ea);
113
114#ifdef _WIN32
115 ea =
116 eina_file_split(strdup(
117 "this\\\\is\\\\\\a \\more\\complex\\\\\\case\\\\\\"));
118#else
119 ea = eina_file_split(strdup("this//is///a /more/complex///case///"));
120#endif
121
122 fail_if(!ea);
123 fail_if(eina_array_count(ea) != 6);
124 fail_if(strcmp(eina_array_data_get(ea, 0), "this"));
125 fail_if(strcmp(eina_array_data_get(ea, 1), "is"));
126 fail_if(strcmp(eina_array_data_get(ea, 2), "a "));
127 fail_if(strcmp(eina_array_data_get(ea, 3), "more"));
128 fail_if(strcmp(eina_array_data_get(ea, 4), "complex"));
129 fail_if(strcmp(eina_array_data_get(ea, 5), "case"));
130
131 eina_array_free(ea);
132
133 eina_shutdown();
134}
135END_TEST
136
137void
138eina_test_file(TCase *tc)
139{
140 tcase_add_test(tc, eina_file_split_simple);
141}
142