1
/* EVIL - EFL library for Windows port
2
* Copyright (C) 2017 Vincent Torri
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.
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.
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/>.
27
#include <evil_private.h>
29
#include "evil_suite.h"
32
_evil_test_stdio_file_new(const char *n, const char *t)
39
if (fwrite(t, 1, strlen(t), f) != strlen(t))
52
_evil_test_stdio_file_new_and_opened(const char *n, const char *t)
59
if (fwrite(t, 1, strlen(t), f) != strlen(t))
69
EFL_START_TEST(evil_stdio_rename_src_file_none)
73
res = rename(NULL, NULL);
76
res = rename("evil_foo.txt", NULL);
81
EFL_START_TEST(evil_stdio_rename_dst_file_none)
88
res1 = _evil_test_stdio_file_new("foo.txt", "test file none");
91
res1 = rename("foo.txt", NULL);
92
res2 = rename("foo.txt", "bar.txt");
93
res3 = _unlink("bar.txt");
94
res4 = _unlink("foo.txt");
103
EFL_START_TEST(evil_stdio_rename_dst_file_exists)
109
res1 = _evil_test_stdio_file_new("foo.txt", "test file exists foo");
112
res2 = _evil_test_stdio_file_new("bar.txt", "test file exists bar");
118
res1 = rename("foo.txt", "bar.txt");
119
res2 = _unlink("bar.txt");
120
res3 = _unlink("foo.txt");
128
EFL_START_TEST(evil_stdio_rename_dst_file_used)
135
f = _evil_test_stdio_file_new_and_opened("foo.txt", "test file used foo");
138
res1 = _evil_test_stdio_file_new("bar.txt", "test file used bar");
147
res1 = rename("foo.txt", "bar.txt");
148
res2 = _unlink("bar.txt");
150
res3 = _unlink("foo.txt");
158
EFL_START_TEST(evil_stdio_rename_dst_file_move_to_dir)
165
res1 = _evil_test_stdio_file_new("foo.txt", "test file move foo");
168
res2 = _mkdir("foo_dir");
171
res1 = rename("foo.txt", "foo_dir/bar.txt");
172
res2 = _unlink("foo_dir/bar.txt");
173
res3 = _rmdir("foo_dir");
174
res4 = _unlink("foo.txt");
183
EFL_START_TEST(evil_stdio_rename_dst_dir_none)
189
res1 = _mkdir("foo_dir");
192
res1 = rename("foo_dir", "bar_dir");
193
res2 = _rmdir("bar_dir");
194
res3 = _rmdir("foo_dir");
202
EFL_START_TEST(evil_stdio_rename_dst_dir_exists)
208
res1 = _mkdir("foo_dir");
211
res1 = _mkdir("bar_dir");
217
res1 = rename("foo_dir", "bar_dir");
218
res2 = _rmdir("bar_dir");
219
res3 = _rmdir("foo_dir");
227
void evil_test_stdio(TCase *tc)
229
tcase_add_test(tc, evil_stdio_rename_src_file_none);
231
tcase_add_test(tc, evil_stdio_rename_dst_file_none);
232
tcase_add_test(tc, evil_stdio_rename_dst_file_exists);
233
tcase_add_test(tc, evil_stdio_rename_dst_file_used);
234
tcase_add_test(tc, evil_stdio_rename_dst_file_move_to_dir);
236
tcase_add_test(tc, evil_stdio_rename_dst_dir_none);
237
tcase_add_test(tc, evil_stdio_rename_dst_dir_exists);