GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
/* |
||
2 |
* The ManaPlus Client |
||
3 |
* Copyright (C) 2016-2019 The ManaPlus Developers |
||
4 |
* Copyright (C) 2019-2021 Andrei Karas |
||
5 |
* |
||
6 |
* This file is part of The ManaPlus Client. |
||
7 |
* |
||
8 |
* This program is free software; you can redistribute it and/or modify |
||
9 |
* it under the terms of the GNU General Public License as published by |
||
10 |
* the Free Software Foundation; either version 2 of the License, or |
||
11 |
* any later version. |
||
12 |
* |
||
13 |
* This program is distributed in the hope that it will be useful, |
||
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
16 |
* GNU General Public License for more details. |
||
17 |
* |
||
18 |
* You should have received a copy of the GNU General Public License |
||
19 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
20 |
*/ |
||
21 |
|||
22 |
#include "unittests/unittests.h" |
||
23 |
|||
24 |
#include "fs/files.h" |
||
25 |
|||
26 |
#include "fs/virtfs/fs.h" |
||
27 |
#include "fs/virtfs/rwops.h" |
||
28 |
|||
29 |
#include "utils/checkutils.h" |
||
30 |
#include "utils/foreach.h" |
||
31 |
#include "utils/stringutils.h" |
||
32 |
|||
33 |
PRAGMA48(GCC diagnostic push) |
||
34 |
PRAGMA48(GCC diagnostic ignored "-Wshadow") |
||
35 |
#include <SDL_rwops.h> |
||
36 |
PRAGMA48(GCC diagnostic pop) |
||
37 |
|||
38 |
#ifndef UNITTESTS_CATCH |
||
39 |
#include <algorithm> |
||
40 |
#endif // UNITTESTS_CATCH |
||
41 |
|||
42 |
#include "debug.h" |
||
43 |
|||
44 |
static bool inList(StringVect list, |
||
45 |
const std::string &name) |
||
46 |
{ |
||
47 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
123 |
FOR_EACH (StringVectCIter, it, list) |
48 |
{ |
||
49 |
✓✓✓✓ ✗✓✓✓ ✓✓✓✓ ✗✓✗✓ ✓✓✗✓ ✓✓✓✓ ✗✓✓✓ ✗✓✓✓ ✗✓✗✓ ✓✓✓✓ ✓✓ |
39 |
if (*it == name) |
50 |
return true; |
||
51 |
} |
||
52 |
return false; |
||
53 |
} |
||
54 |
|||
55 |
17 |
static bool inList(StringVect list, |
|
56 |
const std::string &dir, |
||
57 |
const std::string &name) |
||
58 |
{ |
||
59 |
✓✗ | 51 |
const std::string path = pathJoin(dir, name); |
60 |
✓✗ | 112 |
FOR_EACH (StringVectCIter, it, list) |
61 |
{ |
||
62 |
✓✓ | 44 |
if (*it == path) |
63 |
return true; |
||
64 |
} |
||
65 |
return false; |
||
66 |
} |
||
67 |
|||
68 |
3 |
static void removeTemp(StringVect &restrict list) |
|
69 |
{ |
||
70 |
3 |
int cnt = 0; |
|
71 |
9 |
std::sort(list.begin(), list.end()); |
|
72 |
|||
73 |
✓✓ | 90 |
FOR_EACH (StringVectIter, it, list) |
74 |
{ |
||
75 |
✓✗ | 162 |
if (*it != "serverlistplus.xml.part") |
76 |
{ |
||
77 |
81 |
logger->log("file: %d %s", |
|
78 |
cnt, |
||
79 |
162 |
(*it).c_str()); |
|
80 |
81 |
cnt ++; |
|
81 |
} |
||
82 |
} |
||
83 |
|||
84 |
✓✓ | 90 |
FOR_EACH (StringVectIter, it, list) |
85 |
{ |
||
86 |
✗✓ | 162 |
if (*it == "serverlistplus.xml.part") |
87 |
{ |
||
88 |
list.erase(it); |
||
89 |
return; |
||
90 |
} |
||
91 |
} |
||
92 |
} |
||
93 |
|||
94 |
✓✗ | 3 |
TEST_CASE("VirtFs2 isDirectory1", "") |
95 |
{ |
||
96 |
✓✗ | 4 |
VirtFs::init("."); |
97 |
4 |
std::string name("data/test/test.zip"); |
|
98 |
2 |
std::string prefix; |
|
99 |
✓✗✓✗ |
1 |
if (Files::existsLocal(name) == false) |
100 |
✓✗ | 2 |
prefix = "../" + prefix; |
101 |
|||
102 |
✓✗ | 2 |
VirtFs::mountDir(prefix + "data", |
103 |
✓✗ | 1 |
Append_false); |
104 |
|||
105 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test/units.xml") == false); |
106 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test/units.xml/") == false); |
107 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test//units.xml") == false); |
108 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test/units123.xml") == false); |
109 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test//units123.xml") == false); |
110 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("tesQ/units.xml") == false); |
111 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("tesQ//units.xml") == false); |
112 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("units.xml") == false); |
113 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test") == true); |
114 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test/") == true); |
115 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test//") == true); |
116 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test/dir1") == true); |
117 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test//dir1") == true); |
118 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test//dir1/") == true); |
119 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test//dir1//") == true); |
120 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test\\dir1/") == true); |
121 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test/dir1//") == true); |
122 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("testQ") == false); |
123 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("testQ/") == false); |
124 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("testQ//") == false); |
125 |
|||
126 |
✓✗ | 2 |
VirtFs::mountDir(prefix + "data/test", |
127 |
✓✗ | 1 |
Append_false); |
128 |
|||
129 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test/units.xml") == false); |
130 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test/units.xml/") == false); |
131 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
6 |
REQUIRE(VirtFs::isDirectory("test//units.xml") == false); |
132 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test/units123.xml") == false); |
133 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("tesQ/units.xml") == false); |
134 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("units.xml") == false); |
135 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test") == true); |
136 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("testQ") == false); |
137 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test/dir1") == true); |
138 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test\\dir1") == true); |
139 |
|||
140 |
✓✗✓✗ |
2 |
VirtFs::unmountDir(prefix + "data/test"); |
141 |
|||
142 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test/units.xml") == false); |
143 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test/units123.xml") == false); |
144 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("tesQ/units.xml") == false); |
145 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("units.xml") == false); |
146 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("units.xml/") == false); |
147 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test") == true); |
148 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test/") == true); |
149 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("testQ") == false); |
150 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test/dir1") == true); |
151 |
|||
152 |
✓✗✓✗ |
2 |
VirtFs::unmountDirSilent(prefix + "data"); |
153 |
✓✗ | 1 |
VirtFs::deinit(); |
154 |
1 |
} |
|
155 |
|||
156 |
✓✗ | 3 |
TEST_CASE("VirtFs2 isDirectory2", "") |
157 |
{ |
||
158 |
✓✗ | 4 |
VirtFs::init("."); |
159 |
4 |
std::string name("data/test/test.zip"); |
|
160 |
2 |
std::string prefix; |
|
161 |
✓✗✓✗ |
1 |
if (Files::existsLocal(name) == false) |
162 |
✓✗ | 2 |
prefix = "../" + prefix; |
163 |
|||
164 |
✓✗ | 2 |
VirtFs::mountZip(prefix + "data/test/test2.zip", |
165 |
✓✗ | 1 |
Append_false); |
166 |
|||
167 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2/units.xml") == false); |
168 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2/units.xml/") == false); |
169 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2//units.xml") == false); |
170 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2/units123.xml") == false); |
171 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2//units123.xml") == false); |
172 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("tesQ/units.xml") == false); |
173 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("tesQ//units.xml") == false); |
174 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("units.xml") == false); |
175 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir") == true); |
176 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2/") == true); |
177 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2//") == true); |
178 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir/1") == true); |
179 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir//1") == true); |
180 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir\\1/") == true); |
181 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir/1") == true); |
182 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir/1/zzz") == false); |
183 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test/dir1\\") == false); |
184 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("testQ") == false); |
185 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("testQ/") == false); |
186 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("testQ//") == false); |
187 |
|||
188 |
✓✗ | 2 |
VirtFs::mountZip(prefix + "data/test/test.zip", |
189 |
✓✗ | 1 |
Append_false); |
190 |
|||
191 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2/units.xml") == false); |
192 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2/units.xml/") == false); |
193 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2\\units.xml") == false); |
194 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2/units123.xml") == false); |
195 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2//units123.xml") == false); |
196 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("tesQ/units.xml") == false); |
197 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("tesQ//units.xml") == false); |
198 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("units.xml") == false); |
199 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir") == true); |
200 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2/") == true); |
201 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2\\") == true); |
202 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir/1") == true); |
203 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir//1") == true); |
204 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir//1/") == true); |
205 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir/1") == true); |
206 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir/1/zzz") == false); |
207 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test/dir1//") == false); |
208 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("testQ") == false); |
209 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("testQ/") == false); |
210 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("testQ//") == false); |
211 |
|||
212 |
✓✗✓✗ |
2 |
VirtFs::unmountZip(prefix + "data/test/test2.zip"); |
213 |
|||
214 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2/units.xml") == false); |
215 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2/units.xml/") == false); |
216 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2//units.xml") == false); |
217 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2/units123.xml") == false); |
218 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2//units123.xml") == false); |
219 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("tesQ/units.xml") == false); |
220 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("tesQ//units.xml") == false); |
221 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("units.xml") == false); |
222 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir") == true); |
223 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2/") == false); |
224 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2//") == false); |
225 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir/1") == false); |
226 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir\\1") == false); |
227 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir//1/") == false); |
228 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir/1") == false); |
229 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir/1/zzz") == false); |
230 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test/dir1//") == false); |
231 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("testQ") == false); |
232 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("testQ/") == false); |
233 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("testQ//") == false); |
234 |
|||
235 |
✓✗✓✗ |
2 |
VirtFs::unmountZip(prefix + "data/test/test.zip"); |
236 |
✓✗ | 1 |
VirtFs::deinit(); |
237 |
1 |
} |
|
238 |
|||
239 |
✓✗ | 3 |
TEST_CASE("VirtFs2 isDirectory3", "") |
240 |
{ |
||
241 |
✓✗ | 4 |
VirtFs::init("."); |
242 |
4 |
std::string name("data/test/test.zip"); |
|
243 |
2 |
std::string prefix; |
|
244 |
✓✗✓✗ |
1 |
if (Files::existsLocal(name) == false) |
245 |
✓✗ | 2 |
prefix = "../" + prefix; |
246 |
|||
247 |
✓✗✓✗ |
5 |
VirtFs::mountDir2(prefix + "data", |
248 |
"test", |
||
249 |
✓✗ | 1 |
Append_false); |
250 |
|||
251 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("units.xml") == false); |
252 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("units.xml/") == false); |
253 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("units123.xml") == false); |
254 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("tesQ/units.xml") == false); |
255 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("tesQ//units.xml") == false); |
256 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test") == false); |
257 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir1") == true); |
258 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2//") == true); |
259 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test/dir1") == false); |
260 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("testQ") == false); |
261 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("testQ/") == false); |
262 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("testQ//") == false); |
263 |
|||
264 |
✓✗✓✗ |
5 |
VirtFs::unmountDirSilent2(prefix + "data", |
265 |
✓✗ | 1 |
"test"); |
266 |
✓✗ | 1 |
VirtFs::deinit(); |
267 |
1 |
} |
|
268 |
|||
269 |
✓✗ | 3 |
TEST_CASE("VirtFs2 isDirectory4", "") |
270 |
{ |
||
271 |
✓✗ | 4 |
VirtFs::init("."); |
272 |
4 |
std::string name("data/test/test.zip"); |
|
273 |
2 |
std::string prefix; |
|
274 |
✓✗✓✗ |
1 |
if (Files::existsLocal(name) == false) |
275 |
✓✗ | 2 |
prefix = "../" + prefix; |
276 |
|||
277 |
✓✗✓✗ |
5 |
VirtFs::mountZip2(prefix + "data/test/test2.zip", |
278 |
"dir", |
||
279 |
✓✗ | 1 |
Append_false); |
280 |
|||
281 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2/units.xml") == false); |
282 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2/units.xml/") == false); |
283 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2//units.xml") == false); |
284 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2/units123.xml") == false); |
285 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2//units123.xml") == false); |
286 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("tesQ/units.xml") == false); |
287 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("tesQ//units.xml") == false); |
288 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("units.xml") == false); |
289 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("1") == true); |
290 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("gpl") == true); |
291 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir2/") == false); |
292 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir/1") == false); |
293 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("dir/1/zzz") == false); |
294 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("test/dir1\\") == false); |
295 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("testQ") == false); |
296 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("testQ/") == false); |
297 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(VirtFs::isDirectory("testQ//") == false); |
298 |
|||
299 |
✓✗✓✗ |
5 |
VirtFs::unmountZip2(prefix + "data/test/test2.zip", |
300 |
✓✗ | 1 |
"dir"); |
301 |
✓✗ | 1 |
VirtFs::deinit(); |
302 |
1 |
} |
|
303 |
|||
304 |
✓✗ | 3 |
TEST_CASE("VirtFs2 openRead1", "") |
305 |
{ |
||
306 |
✓✗ | 4 |
VirtFs::init("."); |
307 |
4 |
std::string name("data/test/test.zip"); |
|
308 |
2 |
std::string prefix; |
|
309 |
✓✗✓✗ |
1 |
if (Files::existsLocal(name) == false) |
310 |
✓✗ | 2 |
prefix = "../" + prefix; |
311 |
|||
312 |
✓✗ | 2 |
VirtFs::mountDir(prefix + "data", |
313 |
✓✗ | 1 |
Append_false); |
314 |
|||
315 |
1 |
VirtFs::File *file = nullptr; |
|
316 |
|||
317 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("test/units.xml"); |
318 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
319 |
✓✗ | 1 |
VirtFs::close(file); |
320 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("test\\units.xml"); |
321 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
322 |
✓✗ | 1 |
VirtFs::close(file); |
323 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("test/units123.xml"); |
324 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
325 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("tesQ/units.xml"); |
326 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
327 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("units.xml"); |
328 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
329 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("testQ"); |
330 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
331 |
|||
332 |
✓✗ | 2 |
VirtFs::mountDir(prefix + "data/test", |
333 |
✓✗ | 1 |
Append_false); |
334 |
|||
335 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("test/units.xml"); |
336 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
337 |
✓✗ | 1 |
VirtFs::close(file); |
338 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("test/units123.xml"); |
339 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
340 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("tesQ/units.xml"); |
341 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
342 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("units.xml"); |
343 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
344 |
✓✗ | 1 |
VirtFs::close(file); |
345 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("testQ"); |
346 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
347 |
|||
348 |
✓✗✓✗ |
2 |
VirtFs::unmountDir(prefix + "data/test"); |
349 |
|||
350 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("test/units.xml"); |
351 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
352 |
✓✗ | 1 |
VirtFs::close(file); |
353 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("test/units123.xml"); |
354 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
355 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("tesQ/units.xml"); |
356 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
357 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("units.xml"); |
358 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
359 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("testQ"); |
360 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
361 |
|||
362 |
✓✗✓✗ |
2 |
VirtFs::unmountDir(prefix + "data"); |
363 |
✓✗ | 1 |
VirtFs::deinit(); |
364 |
1 |
} |
|
365 |
|||
366 |
✓✗ | 3 |
TEST_CASE("VirtFs2 openRead2", "") |
367 |
{ |
||
368 |
✓✗ | 4 |
VirtFs::init("."); |
369 |
4 |
std::string name("data/test/test.zip"); |
|
370 |
✓✗ | 4 |
std::string prefix("data/test/"); |
371 |
✓✗✓✗ |
1 |
if (Files::existsLocal(name) == false) |
372 |
✓✗ | 2 |
prefix = "../" + prefix; |
373 |
|||
374 |
✓✗ | 2 |
VirtFs::mountZip(prefix + "test2.zip", |
375 |
✓✗ | 1 |
Append_false); |
376 |
|||
377 |
1 |
VirtFs::File *file = nullptr; |
|
378 |
|||
379 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dir2/units.xml"); |
380 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
381 |
✓✗ | 1 |
VirtFs::close(file); |
382 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dir2\\units.xml"); |
383 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
384 |
✓✗ | 1 |
VirtFs::close(file); |
385 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dir2/units123.xml"); |
386 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
387 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("tesQ/units.xml"); |
388 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
389 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("units.xml1"); |
390 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
391 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("testQ"); |
392 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
393 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dir/brimmedhat.png"); |
394 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
395 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dir//brimmedhat.png"); |
396 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
397 |
|||
398 |
✓✗ | 2 |
VirtFs::mountZip(prefix + "test.zip", |
399 |
✓✗ | 1 |
Append_false); |
400 |
|||
401 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dir2/units.xml"); |
402 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
403 |
✓✗ | 1 |
VirtFs::close(file); |
404 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dir2//units.xml"); |
405 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
406 |
✓✗ | 1 |
VirtFs::close(file); |
407 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dir2/units123.xml"); |
408 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
409 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("tesQ/units.xml"); |
410 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
411 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("units.xml1"); |
412 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
413 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("testQ"); |
414 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
415 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dir/brimmedhat.png"); |
416 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
417 |
✓✗ | 1 |
VirtFs::close(file); |
418 |
|||
419 |
✓✗✓✗ |
2 |
VirtFs::unmountZip(prefix + "test.zip"); |
420 |
|||
421 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dir2/units.xml"); |
422 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
423 |
✓✗ | 1 |
VirtFs::close(file); |
424 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dir2\\/\\units.xml"); |
425 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
426 |
✓✗ | 1 |
VirtFs::close(file); |
427 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dir2/units123.xml"); |
428 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
429 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("tesQ/units.xml"); |
430 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
431 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("units.xml1"); |
432 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
433 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("testQ"); |
434 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
435 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dir/brimmedhat.png"); |
436 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
437 |
|||
438 |
✓✗✓✗ |
2 |
VirtFs::unmountZip(prefix + "test2.zip"); |
439 |
|||
440 |
✓✗ | 1 |
VirtFs::deinit(); |
441 |
1 |
} |
|
442 |
|||
443 |
✓✗ | 3 |
TEST_CASE("VirtFs2 openRead3", "") |
444 |
{ |
||
445 |
✓✗ | 4 |
VirtFs::init("."); |
446 |
4 |
std::string name("data/test/test.zip"); |
|
447 |
2 |
std::string prefix; |
|
448 |
✓✗✓✗ |
1 |
if (Files::existsLocal(name) == false) |
449 |
✓✗ | 2 |
prefix = "../" + prefix; |
450 |
|||
451 |
✓✗✓✗ |
5 |
VirtFs::mountDir2(prefix + "data", |
452 |
"test", |
||
453 |
✓✗ | 1 |
Append_false); |
454 |
|||
455 |
1 |
VirtFs::File *file = nullptr; |
|
456 |
|||
457 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("units.xml"); |
458 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
459 |
✓✗ | 1 |
VirtFs::close(file); |
460 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("test/units.xml"); |
461 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
462 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("units123.xml"); |
463 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
464 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("tesQ/units.xml"); |
465 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
466 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("testQ"); |
467 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
468 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("file1.txt"); |
469 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
470 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("file2.txt"); |
471 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
472 |
|||
473 |
✓✗✓✗ |
5 |
VirtFs::mountDir2(prefix + "data/test", |
474 |
"dir2", |
||
475 |
✓✗ | 1 |
Append_false); |
476 |
|||
477 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("units.xml"); |
478 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
479 |
✓✗ | 1 |
VirtFs::close(file); |
480 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("test/units.xml"); |
481 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
482 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("units123.xml"); |
483 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
484 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("tesQ/units.xml"); |
485 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
486 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("testQ"); |
487 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
488 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("file1.txt"); |
489 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
490 |
✓✗ | 1 |
VirtFs::close(file); |
491 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("file2.txt"); |
492 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
493 |
✓✗ | 1 |
VirtFs::close(file); |
494 |
|||
495 |
✓✗✓✗ |
5 |
VirtFs::unmountDir2(prefix + "data/test", |
496 |
✓✗ | 1 |
"dir2"); |
497 |
|||
498 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("units.xml"); |
499 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
500 |
✓✗ | 1 |
VirtFs::close(file); |
501 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("test/units.xml"); |
502 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
503 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("units123.xml"); |
504 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
505 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("tesQ/units.xml"); |
506 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
507 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("testQ"); |
508 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
509 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("file1.txt"); |
510 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
511 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("file2.txt"); |
512 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
513 |
|||
514 |
✓✗✓✗ |
5 |
VirtFs::unmountDir2(prefix + "data", |
515 |
✓✗ | 1 |
"test"); |
516 |
✓✗ | 1 |
VirtFs::deinit(); |
517 |
1 |
} |
|
518 |
|||
519 |
✓✗ | 3 |
TEST_CASE("VirtFs2 openRead4", "") |
520 |
{ |
||
521 |
✓✗ | 4 |
VirtFs::init("."); |
522 |
4 |
std::string name("data/test/test.zip"); |
|
523 |
✓✗ | 4 |
std::string prefix("data/test/"); |
524 |
✓✗✓✗ |
1 |
if (Files::existsLocal(name) == false) |
525 |
✓✗ | 2 |
prefix = "../" + prefix; |
526 |
|||
527 |
✓✗✓✗ |
5 |
VirtFs::mountZip2(prefix + "test2.zip", |
528 |
"dir", |
||
529 |
✓✗ | 1 |
Append_false); |
530 |
|||
531 |
1 |
VirtFs::File *file = nullptr; |
|
532 |
|||
533 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dye.png"); |
534 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
535 |
✓✗ | 1 |
VirtFs::close(file); |
536 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("1\\test.txt"); |
537 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
538 |
✓✗ | 1 |
VirtFs::close(file); |
539 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dir/dye.png"); |
540 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
541 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("tesQ/units.xml"); |
542 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
543 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dye.png1"); |
544 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
545 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("testQ"); |
546 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
547 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("brimmedhat.png"); |
548 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
549 |
|||
550 |
✓✗✓✗ |
5 |
VirtFs::mountZip2(prefix + "test.zip", |
551 |
"dir", |
||
552 |
✓✗ | 1 |
Append_false); |
553 |
|||
554 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dye.png"); |
555 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
556 |
✓✗ | 1 |
VirtFs::close(file); |
557 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("1\\test.txt"); |
558 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
559 |
✓✗ | 1 |
VirtFs::close(file); |
560 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dir/dye.png"); |
561 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
562 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("tesQ/units.xml"); |
563 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
564 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dye.png1"); |
565 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
566 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("testQ"); |
567 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
568 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("brimmedhat.png"); |
569 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
570 |
✓✗ | 1 |
VirtFs::close(file); |
571 |
|||
572 |
✓✗✓✗ |
5 |
VirtFs::unmountZip2(prefix + "test.zip", |
573 |
✓✗ | 1 |
"dir"); |
574 |
|||
575 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dye.png"); |
576 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
577 |
✓✗ | 1 |
VirtFs::close(file); |
578 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("1\\test.txt"); |
579 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
580 |
✓✗ | 1 |
VirtFs::close(file); |
581 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dir/dye.png"); |
582 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
583 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("tesQ/units.xml"); |
584 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
585 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dye.png1"); |
586 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
587 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("testQ"); |
588 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
589 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("brimmedhat.png"); |
590 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file == nullptr); |
591 |
|||
592 |
✓✗✓✗ |
5 |
VirtFs::unmountZip2(prefix + "test2.zip", |
593 |
✓✗ | 1 |
"dir"); |
594 |
|||
595 |
✓✗ | 1 |
VirtFs::deinit(); |
596 |
1 |
} |
|
597 |
|||
598 |
✓✗ | 3 |
TEST_CASE("VirtFs2 permitLinks", "") |
599 |
{ |
||
600 |
✓✗ | 4 |
VirtFs::init("."); |
601 |
4 |
std::string name("data/test/test.zip"); |
|
602 |
2 |
std::string prefix; |
|
603 |
✓✗✓✗ |
1 |
if (Files::existsLocal(name) == false) |
604 |
✓✗ | 2 |
prefix = "../" + prefix; |
605 |
|||
606 |
✓✗ | 2 |
VirtFs::mountDir(prefix + "data", |
607 |
✓✗ | 1 |
Append_false); |
608 |
|||
609 |
✓✗✓✗ ✗✓ |
4 |
const int cnt1 = VirtFs::exists("test/test2.txt") ? 27 : 26; |
610 |
1 |
const int cnt2 = 27; |
|
611 |
|||
612 |
2 |
StringVect list; |
|
613 |
✓✗ | 1 |
VirtFs::permitLinks(false); |
614 |
✓✗✓✗ |
4 |
VirtFs::getFiles("test", list); |
615 |
✓✗ | 1 |
removeTemp(list); |
616 |
2 |
const size_t sz = list.size(); |
|
617 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(sz == cnt1); |
618 |
|||
619 |
1 |
list.clear(); |
|
620 |
✓✗ | 1 |
VirtFs::permitLinks(true); |
621 |
✓✗✓✗ |
4 |
VirtFs::getFiles("test", list); |
622 |
✓✗ | 1 |
removeTemp(list); |
623 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(list.size() == cnt2); |
624 |
|||
625 |
1 |
list.clear(); |
|
626 |
✓✗ | 1 |
VirtFs::permitLinks(false); |
627 |
✓✗✓✗ |
4 |
VirtFs::getFiles("test", list); |
628 |
✓✗ | 1 |
removeTemp(list); |
629 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(list.size() == cnt1); |
630 |
|||
631 |
✓✗✓✗ |
2 |
VirtFs::unmountDirSilent(prefix + "data"); |
632 |
✓✗ | 1 |
VirtFs::deinit(); |
633 |
1 |
} |
|
634 |
|||
635 |
✓✗ | 3 |
TEST_CASE("VirtFs2 read1", "") |
636 |
{ |
||
637 |
✓✗ | 4 |
VirtFs::init("."); |
638 |
4 |
std::string name("data/test/test.zip"); |
|
639 |
2 |
std::string prefix; |
|
640 |
✓✗✓✗ |
1 |
if (Files::existsLocal(name) == false) |
641 |
✓✗ | 2 |
prefix = "../" + prefix; |
642 |
|||
643 |
✓✗ | 2 |
VirtFs::mountDir(prefix + "data", |
644 |
✓✗ | 1 |
Append_false); |
645 |
|||
646 |
✓✗✓✗ |
4 |
VirtFs::File *file = VirtFs::openRead("test/test.txt"); |
647 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
648 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::fileLength(file) == 23); |
649 |
✓✗ | 1 |
const int fileSize = VirtFs::fileLength(file); |
650 |
|||
651 |
1 |
void *restrict buffer = calloc(fileSize + 1, 1); |
|
652 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::read(file, buffer, 1, fileSize) == fileSize); |
653 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(strcmp(static_cast<char*>(buffer), |
654 |
"test line 1\ntest line 2") == 0); |
||
655 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::tell(file) == fileSize); |
656 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::eof(file) != 0); |
657 |
|||
658 |
1 |
free(buffer); |
|
659 |
1 |
buffer = calloc(fileSize + 1, 1); |
|
660 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::seek(file, 12) != 0); |
661 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::eof(file) == 0); |
662 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::tell(file) == 12); |
663 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::read(file, buffer, 1, 11) == 11); |
664 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(strcmp(static_cast<char*>(buffer), |
665 |
"test line 2") == 0); |
||
666 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::eof(file) != 0); |
667 |
|||
668 |
✓✗ | 1 |
VirtFs::close(file); |
669 |
1 |
free(buffer); |
|
670 |
|||
671 |
✓✗✓✗ |
2 |
VirtFs::unmountDir(prefix + "data"); |
672 |
✓✗ | 1 |
VirtFs::deinit(); |
673 |
1 |
} |
|
674 |
|||
675 |
✓✗ | 8 |
TEST_CASE("VirtFs2 read2", "") |
676 |
{ |
||
677 |
✓✗ | 24 |
VirtFs::init("."); |
678 |
24 |
std::string name("data/test/test.zip"); |
|
679 |
✓✗ | 24 |
std::string prefix("data/test/"); |
680 |
✓✗✓✗ |
6 |
if (Files::existsLocal(name) == false) |
681 |
✓✗ | 12 |
prefix = "../" + prefix; |
682 |
|||
683 |
✓✗ | 12 |
VirtFs::mountZip(prefix + "test2.zip", |
684 |
✓✗ | 6 |
Append_false); |
685 |
6 |
VirtFs::File *file = nullptr; |
|
686 |
6 |
void *restrict buffer = nullptr; |
|
687 |
|||
688 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
42 |
SECTION("test 1") |
689 |
{ |
||
690 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dir2//test.txt"); |
691 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
692 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::fileLength(file) == 23); |
693 |
✓✗ | 1 |
const int fileSize = VirtFs::fileLength(file); |
694 |
|||
695 |
1 |
buffer = calloc(fileSize + 1, 1); |
|
696 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::read(file, buffer, 1, fileSize) == fileSize); |
697 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(strcmp(static_cast<char*>(buffer), |
698 |
"test line 1\ntest line 2") == 0); |
||
699 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::tell(file) == fileSize); |
700 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::eof(file) != 0); |
701 |
} |
||
702 |
|||
703 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
42 |
SECTION("test 2") |
704 |
{ |
||
705 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dir2\\/test.txt"); |
706 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
707 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::fileLength(file) == 23); |
708 |
✓✗ | 1 |
const int fileSize = VirtFs::fileLength(file); |
709 |
|||
710 |
1 |
buffer = calloc(fileSize + 1, 1); |
|
711 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::seek(file, 12) != 0); |
712 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::eof(file) == 0); |
713 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::tell(file) == 12); |
714 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::read(file, buffer, 1, 11) == 11); |
715 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(strcmp(static_cast<char*>(buffer), |
716 |
"test line 2") == 0); |
||
717 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::eof(file) != 0); |
718 |
} |
||
719 |
|||
720 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
42 |
SECTION("test 3") |
721 |
{ |
||
722 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dir2//test.txt"); |
723 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
724 |
✓✗ | 1 |
const int fileSize = VirtFs::fileLength(file); |
725 |
|||
726 |
1 |
buffer = calloc(fileSize + 1, 1); |
|
727 |
✓✓ | 24 |
for (int f = 0; f < fileSize; f ++) |
728 |
{ |
||
729 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
92 |
REQUIRE(VirtFs::seek(file, f) != 0); |
730 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
92 |
REQUIRE(VirtFs::eof(file) == 0); |
731 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
92 |
REQUIRE(VirtFs::tell(file) == f); |
732 |
} |
||
733 |
} |
||
734 |
|||
735 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
42 |
SECTION("test 4") |
736 |
{ |
||
737 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dir2/test.txt"); |
738 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
739 |
✓✗ | 1 |
const int fileSize = VirtFs::fileLength(file); |
740 |
1 |
const char *restrict const str = "test line 1\ntest line 2"; |
|
741 |
1 |
buffer = calloc(fileSize + 1, 1); |
|
742 |
✓✓ | 23 |
for (int f = 0; f < fileSize - 1; f ++) |
743 |
{ |
||
744 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
88 |
REQUIRE(VirtFs::read(file, buffer, 1, 1) == 1); |
745 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
88 |
REQUIRE(static_cast<char*>(buffer)[0] == str[f]); |
746 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
88 |
REQUIRE(VirtFs::eof(file) == 0); |
747 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
88 |
REQUIRE(VirtFs::tell(file) == f + 1); |
748 |
} |
||
749 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::read(file, buffer, 1, 1) == 1); |
750 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(static_cast<char*>(buffer)[0] == str[22]); |
751 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::eof(file) != 0); |
752 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::tell(file) == fileSize); |
753 |
} |
||
754 |
|||
755 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
42 |
SECTION("test 5") |
756 |
{ |
||
757 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dir2\\\\test.txt"); |
758 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
759 |
✓✗ | 1 |
const int fileSize = VirtFs::fileLength(file); |
760 |
1 |
const char *restrict const str = "test line 1\ntest line 2"; |
|
761 |
1 |
buffer = calloc(fileSize + 1, 1); |
|
762 |
✓✓ | 12 |
for (int f = 0; f < fileSize - 1; f += 2) |
763 |
{ |
||
764 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(VirtFs::read(file, buffer, 2, 1) == 1); |
765 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
44 |
REQUIRE(static_cast<char*>(buffer)[0] == str[f]); |
766 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
44 |
REQUIRE(static_cast<char*>(buffer)[1] == str[f + 1]); |
767 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(VirtFs::eof(file) == 0); |
768 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(VirtFs::tell(file) == f + 2); |
769 |
} |
||
770 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::eof(file) == 0); |
771 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::tell(file) == 22); |
772 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::read(file, buffer, 2, 1) == 0); |
773 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::eof(file) == 0); |
774 |
} |
||
775 |
|||
776 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
42 |
SECTION("test 6") |
777 |
{ |
||
778 |
✓✗✓✗ |
4 |
file = VirtFs::openRead("dir2//test.txt"); |
779 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
780 |
✓✗ | 1 |
const int fileSize = VirtFs::fileLength(file); |
781 |
1 |
const char *restrict const str = "test line 1\ntest line 2"; |
|
782 |
1 |
buffer = calloc(fileSize + 1, 1); |
|
783 |
✓✓ | 12 |
for (int f = 0; f < fileSize - 1; f += 2) |
784 |
{ |
||
785 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(VirtFs::read(file, buffer, 1, 2) == 2); |
786 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
44 |
REQUIRE(static_cast<char*>(buffer)[0] == str[f]); |
787 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
44 |
REQUIRE(static_cast<char*>(buffer)[1] == str[f + 1]); |
788 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(VirtFs::eof(file) == 0); |
789 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(VirtFs::tell(file) == f + 2); |
790 |
} |
||
791 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::eof(file) == 0); |
792 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::tell(file) == 22); |
793 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::read(file, buffer, 1, 2) == 1); |
794 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(static_cast<char*>(buffer)[0] == str[22]); |
795 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::eof(file) != 0); |
796 |
} |
||
797 |
|||
798 |
✓✗ | 6 |
VirtFs::close(file); |
799 |
6 |
free(buffer); |
|
800 |
✓✗✓✗ |
12 |
VirtFs::unmountZip(prefix + "test2.zip"); |
801 |
✓✗ | 6 |
VirtFs::deinit(); |
802 |
6 |
} |
|
803 |
|||
804 |
✓✗ | 3 |
TEST_CASE("VirtFs2 loadFile1", "") |
805 |
{ |
||
806 |
✓✗ | 4 |
VirtFs::init("."); |
807 |
1 |
int fileSize = 0; |
|
808 |
4 |
std::string name("data/test/test.zip"); |
|
809 |
2 |
std::string prefix; |
|
810 |
✓✗✓✗ |
1 |
if (Files::existsLocal(name) == false) |
811 |
✓✗ | 2 |
prefix = "../" + prefix; |
812 |
|||
813 |
✓✗ | 2 |
VirtFs::mountDir(prefix + "data", |
814 |
✓✗ | 1 |
Append_false); |
815 |
|||
816 |
✓✗✓✗ |
4 |
const char *const buffer = VirtFs::loadFile("test/test.txt", fileSize); |
817 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(static_cast<const void*>(buffer) != nullptr); |
818 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(fileSize == 23); |
819 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(strncmp(buffer, "test line 1\ntest line 2", 23) == 0); |
820 |
✓✗ | 1 |
delete [] buffer; |
821 |
|||
822 |
✓✗✓✗ |
2 |
VirtFs::unmountDir(prefix + "data"); |
823 |
✓✗ | 1 |
VirtFs::deinit(); |
824 |
1 |
} |
|
825 |
|||
826 |
✓✗ | 4 |
TEST_CASE("VirtFs2 loadFile2", "") |
827 |
{ |
||
828 |
✓✗ | 8 |
VirtFs::init("."); |
829 |
2 |
int fileSize = 0; |
|
830 |
8 |
std::string name("data/test/test.zip"); |
|
831 |
4 |
std::string prefix; |
|
832 |
✓✗✓✗ |
2 |
if (Files::existsLocal(name) == false) |
833 |
✓✗ | 4 |
prefix = "../" + prefix; |
834 |
|||
835 |
✓✗ | 4 |
VirtFs::mountZip(prefix + "data/test/test2.zip", |
836 |
✓✗ | 2 |
Append_false); |
837 |
|||
838 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
14 |
SECTION("test 1") |
839 |
{ |
||
840 |
✓✗ | 4 |
const char *restrict buffer = VirtFs::loadFile("dir2//test.txt", |
841 |
✓✗ | 1 |
fileSize); |
842 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(static_cast<const void*>(buffer) != nullptr); |
843 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(fileSize == 23); |
844 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(strncmp(buffer, "test line 1\ntest line 2", 23) == 0); |
845 |
✓✗ | 1 |
delete [] buffer; |
846 |
} |
||
847 |
|||
848 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
14 |
SECTION("test 2") |
849 |
{ |
||
850 |
✓✗ | 4 |
const char *restrict buffer = VirtFs::loadFile("dir2\\/test.txt", |
851 |
✓✗ | 1 |
fileSize); |
852 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(static_cast<const void*>(buffer) != nullptr); |
853 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(fileSize == 23); |
854 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(strncmp(buffer, "test line 1\ntest line 2", 23) == 0); |
855 |
✓✗ | 1 |
delete [] buffer; |
856 |
} |
||
857 |
|||
858 |
✓✗✓✗ |
4 |
VirtFs::unmountZip(prefix + "data/test/test2.zip"); |
859 |
✓✗ | 2 |
VirtFs::deinit(); |
860 |
2 |
} |
|
861 |
|||
862 |
✓✗ | 3 |
TEST_CASE("VirtFs2 loadFile3", "") |
863 |
{ |
||
864 |
✓✗ | 4 |
VirtFs::init("."); |
865 |
1 |
int fileSize = 0; |
|
866 |
4 |
std::string name("data/test/test.zip"); |
|
867 |
2 |
std::string prefix; |
|
868 |
✓✗✓✗ |
1 |
if (Files::existsLocal(name) == false) |
869 |
✓✗ | 2 |
prefix = "../" + prefix; |
870 |
|||
871 |
✓✗✓✗ |
5 |
VirtFs::mountDir2(prefix + "data", |
872 |
"test", |
||
873 |
✓✗ | 1 |
Append_false); |
874 |
|||
875 |
✓✗✓✗ |
4 |
const char *const buffer = VirtFs::loadFile("test.txt", fileSize); |
876 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(static_cast<const void*>(buffer) != nullptr); |
877 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(fileSize == 23); |
878 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(strncmp(buffer, "test line 1\ntest line 2", 23) == 0); |
879 |
✓✗ | 1 |
delete [] buffer; |
880 |
|||
881 |
✓✗✓✗ |
5 |
VirtFs::unmountDir2(prefix + "data", |
882 |
✓✗ | 1 |
"test"); |
883 |
✓✗ | 1 |
VirtFs::deinit(); |
884 |
1 |
} |
|
885 |
|||
886 |
✓✗ | 4 |
TEST_CASE("VirtFs2 loadFile4", "") |
887 |
{ |
||
888 |
✓✗ | 8 |
VirtFs::init("."); |
889 |
2 |
int fileSize = 0; |
|
890 |
8 |
std::string name("data/test/test.zip"); |
|
891 |
4 |
std::string prefix; |
|
892 |
✓✗✓✗ |
2 |
if (Files::existsLocal(name) == false) |
893 |
✓✗ | 4 |
prefix = "../" + prefix; |
894 |
|||
895 |
✓✗✓✗ |
10 |
VirtFs::mountZip2(prefix + "data/test/test2.zip", |
896 |
"dir2", |
||
897 |
✓✗ | 2 |
Append_false); |
898 |
|||
899 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
14 |
SECTION("test 1") |
900 |
{ |
||
901 |
✓✗ | 4 |
const char *restrict buffer = VirtFs::loadFile("test.txt", |
902 |
✓✗ | 1 |
fileSize); |
903 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(static_cast<const void*>(buffer) != nullptr); |
904 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(fileSize == 23); |
905 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(strncmp(buffer, "test line 1\ntest line 2", 23) == 0); |
906 |
✓✗ | 1 |
delete [] buffer; |
907 |
} |
||
908 |
|||
909 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
14 |
SECTION("test 2") |
910 |
{ |
||
911 |
✓✗ | 4 |
const char *restrict buffer = VirtFs::loadFile("test.txt", |
912 |
✓✗ | 1 |
fileSize); |
913 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(static_cast<const void*>(buffer) != nullptr); |
914 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(fileSize == 23); |
915 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(strncmp(buffer, "test line 1\ntest line 2", 23) == 0); |
916 |
✓✗ | 1 |
delete [] buffer; |
917 |
} |
||
918 |
|||
919 |
✓✗✓✗ |
10 |
VirtFs::unmountZip2(prefix + "data/test/test2.zip", |
920 |
✓✗ | 2 |
"dir2"); |
921 |
✓✗ | 2 |
VirtFs::deinit(); |
922 |
2 |
} |
|
923 |
|||
924 |
✓✗ | 3 |
TEST_CASE("VirtFs2 rwops_read1", "") |
925 |
{ |
||
926 |
✓✗ | 4 |
VirtFs::init("."); |
927 |
4 |
std::string name("data/test/test.zip"); |
|
928 |
2 |
std::string prefix; |
|
929 |
✓✗✓✗ |
1 |
if (Files::existsLocal(name) == false) |
930 |
✓✗ | 2 |
prefix = "../" + prefix; |
931 |
|||
932 |
✓✗ | 2 |
VirtFs::mountDir(prefix + "data", |
933 |
✓✗ | 1 |
Append_false); |
934 |
|||
935 |
✓✗✓✗ |
4 |
SDL_RWops *file = VirtFs::rwopsOpenRead("test/test.txt"); |
936 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
937 |
#ifdef USE_SDL2 |
||
938 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->size(file) == 23); |
939 |
#endif // USE_SDL2 |
||
940 |
|||
941 |
1 |
const int fileSize = 23; |
|
942 |
|||
943 |
1 |
void *restrict buffer = calloc(fileSize + 1, 1); |
|
944 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->read(file, buffer, 1, fileSize) == fileSize); |
945 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(strcmp(static_cast<char*>(buffer), |
946 |
"test line 1\ntest line 2") == 0); |
||
947 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == fileSize); |
948 |
|||
949 |
1 |
free(buffer); |
|
950 |
1 |
buffer = calloc(fileSize + 1, 1); |
|
951 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->seek(file, 12, SEEK_SET) != 0); |
952 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == 12); |
953 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->read(file, buffer, 1, 11) == 11); |
954 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(strcmp(static_cast<char*>(buffer), |
955 |
"test line 2") == 0); |
||
956 |
|||
957 |
✓✗ | 1 |
file->close(file); |
958 |
1 |
free(buffer); |
|
959 |
|||
960 |
✓✗✓✗ |
2 |
VirtFs::unmountDir(prefix + "data"); |
961 |
✓✗ | 1 |
VirtFs::deinit(); |
962 |
1 |
} |
|
963 |
|||
964 |
✓✗ | 10 |
TEST_CASE("VirtFs2 rwops_read2", "") |
965 |
{ |
||
966 |
✓✗ | 32 |
VirtFs::init("."); |
967 |
32 |
std::string name("data/test/test.zip"); |
|
968 |
✓✗ | 32 |
std::string prefix("data/test/"); |
969 |
✓✗✓✗ |
8 |
if (Files::existsLocal(name) == false) |
970 |
✓✗ | 16 |
prefix = "../" + prefix; |
971 |
|||
972 |
✓✗ | 16 |
VirtFs::mountZip(prefix + "test2.zip", |
973 |
✓✗ | 8 |
Append_false); |
974 |
8 |
SDL_RWops *file = nullptr; |
|
975 |
8 |
void *restrict buffer = nullptr; |
|
976 |
|||
977 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
56 |
SECTION("test 1") |
978 |
{ |
||
979 |
✓✗✓✗ |
4 |
file = VirtFs::rwopsOpenRead("dir2//test.txt"); |
980 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
981 |
#ifdef USE_SDL2 |
||
982 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->size(file) == 23); |
983 |
#endif // USE_SDL2 |
||
984 |
1 |
const int fileSize = 23; |
|
985 |
|||
986 |
1 |
buffer = calloc(fileSize + 1, 1); |
|
987 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->read(file, buffer, 1, fileSize) == fileSize); |
988 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(strcmp(static_cast<char*>(buffer), |
989 |
"test line 1\ntest line 2") == 0); |
||
990 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == fileSize); |
991 |
} |
||
992 |
|||
993 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
56 |
SECTION("test 2") |
994 |
{ |
||
995 |
✓✗✓✗ |
4 |
file = VirtFs::rwopsOpenRead("dir2\\/test.txt"); |
996 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
997 |
#ifdef USE_SDL2 |
||
998 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->size(file) == 23); |
999 |
#endif // USE_SDL2 |
||
1000 |
1 |
const int fileSize = 23; |
|
1001 |
|||
1002 |
1 |
buffer = calloc(fileSize + 1, 1); |
|
1003 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->seek(file, 12, SEEK_SET) != 0); |
1004 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == 12); |
1005 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->read(file, buffer, 1, 11) == 11); |
1006 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(strcmp(static_cast<char*>(buffer), |
1007 |
"test line 2") == 0); |
||
1008 |
} |
||
1009 |
|||
1010 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
56 |
SECTION("test 3") |
1011 |
{ |
||
1012 |
✓✗✓✗ |
4 |
file = VirtFs::rwopsOpenRead("dir2//test.txt"); |
1013 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
1014 |
1 |
const int fileSize = 23; |
|
1015 |
|||
1016 |
1 |
buffer = calloc(fileSize + 1, 1); |
|
1017 |
✓✓ | 24 |
for (int f = 0; f < fileSize; f ++) |
1018 |
{ |
||
1019 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
92 |
REQUIRE(file->seek(file, f, SEEK_SET) == f); |
1020 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
92 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == f); |
1021 |
} |
||
1022 |
} |
||
1023 |
|||
1024 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
56 |
SECTION("test 4") |
1025 |
{ |
||
1026 |
✓✗✓✗ |
4 |
file = VirtFs::rwopsOpenRead("dir2/test.txt"); |
1027 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
1028 |
1 |
const int fileSize = 23; |
|
1029 |
1 |
const char *restrict const str = "test line 1\ntest line 2"; |
|
1030 |
1 |
buffer = calloc(fileSize + 1, 1); |
|
1031 |
✓✓ | 23 |
for (int f = 0; f < fileSize - 1; f ++) |
1032 |
{ |
||
1033 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
88 |
REQUIRE(file->read(file, buffer, 1, 1) == 1); |
1034 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
88 |
REQUIRE(static_cast<char*>(buffer)[0] == str[f]); |
1035 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
88 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == f + 1); |
1036 |
} |
||
1037 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->read(file, buffer, 1, 1) == 1); |
1038 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(static_cast<char*>(buffer)[0] == str[22]); |
1039 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == fileSize); |
1040 |
} |
||
1041 |
|||
1042 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
56 |
SECTION("test 5") |
1043 |
{ |
||
1044 |
✓✗✓✗ |
4 |
file = VirtFs::rwopsOpenRead("dir2\\\\test.txt"); |
1045 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
1046 |
1 |
const int fileSize = 23; |
|
1047 |
1 |
const char *restrict const str = "test line 1\ntest line 2"; |
|
1048 |
1 |
buffer = calloc(fileSize + 1, 1); |
|
1049 |
✓✓ | 12 |
for (int f = 0; f < fileSize - 1; f += 2) |
1050 |
{ |
||
1051 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(file->read(file, buffer, 2, 1) == 1); |
1052 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
44 |
REQUIRE(static_cast<char*>(buffer)[0] == str[f]); |
1053 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
44 |
REQUIRE(static_cast<char*>(buffer)[1] == str[f + 1]); |
1054 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == f + 2); |
1055 |
} |
||
1056 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == 22); |
1057 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->read(file, buffer, 2, 1) == 0); |
1058 |
} |
||
1059 |
|||
1060 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
56 |
SECTION("test 6") |
1061 |
{ |
||
1062 |
✓✗✓✗ |
4 |
file = VirtFs::rwopsOpenRead("dir2//test.txt"); |
1063 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
1064 |
1 |
const int fileSize = 23; |
|
1065 |
1 |
const char *restrict const str = "test line 1\ntest line 2"; |
|
1066 |
1 |
buffer = calloc(fileSize + 1, 1); |
|
1067 |
✓✓ | 12 |
for (int f = 0; f < fileSize - 1; f += 2) |
1068 |
{ |
||
1069 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(file->read(file, buffer, 1, 2) == 2); |
1070 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
44 |
REQUIRE(static_cast<char*>(buffer)[0] == str[f]); |
1071 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
44 |
REQUIRE(static_cast<char*>(buffer)[1] == str[f + 1]); |
1072 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == f + 2); |
1073 |
} |
||
1074 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == 22); |
1075 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->read(file, buffer, 1, 2) == 1); |
1076 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(static_cast<char*>(buffer)[0] == str[22]); |
1077 |
} |
||
1078 |
|||
1079 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
56 |
SECTION("test 7") |
1080 |
{ |
||
1081 |
✓✗✓✗ |
4 |
file = VirtFs::rwopsOpenRead("dir2//test.txt"); |
1082 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
1083 |
1 |
const int fileSize = 23; |
|
1084 |
1 |
const char *restrict const str = "test line 1\ntest line 2"; |
|
1085 |
1 |
buffer = calloc(fileSize + 1, 1); |
|
1086 |
✓✓ | 12 |
for (int f = 0; f < fileSize - 1; f += 2) |
1087 |
{ |
||
1088 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(file->read(file, buffer, 1, 2) == 2); |
1089 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(file->seek(file, -2, SEEK_CUR) == f); |
1090 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == f); |
1091 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(file->seek(file, 2, SEEK_CUR) == f + 2); |
1092 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
44 |
REQUIRE(static_cast<char*>(buffer)[0] == str[f]); |
1093 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
44 |
REQUIRE(static_cast<char*>(buffer)[1] == str[f + 1]); |
1094 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == f + 2); |
1095 |
} |
||
1096 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == 22); |
1097 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->read(file, buffer, 1, 2) == 1); |
1098 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(static_cast<char*>(buffer)[0] == str[22]); |
1099 |
} |
||
1100 |
|||
1101 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
56 |
SECTION("test 8") |
1102 |
{ |
||
1103 |
✓✗✓✗ |
4 |
file = VirtFs::rwopsOpenRead("dir2//test.txt"); |
1104 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
1105 |
1 |
const int fileSize = 23; |
|
1106 |
1 |
const char *restrict const str = "test line 1\ntest line 2"; |
|
1107 |
1 |
buffer = calloc(fileSize + 1, 1); |
|
1108 |
✓✓ | 12 |
for (int f = 0; f < fileSize - 1; f += 2) |
1109 |
{ |
||
1110 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(file->seek(file, -f - 2, SEEK_END) == 23 - f - 2); |
1111 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(file->read(file, buffer, 1, 2) == 2); |
1112 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
44 |
REQUIRE(static_cast<char*>(buffer)[0] == str[23 - f - 2]); |
1113 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
44 |
REQUIRE(static_cast<char*>(buffer)[1] == str[23 - f - 2 + 1]); |
1114 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == 23 - f); |
1115 |
} |
||
1116 |
// 3 |
||
1117 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->seek(file, 1, SEEK_CUR) == 4); |
1118 |
// 4 |
||
1119 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->read(file, buffer, 1, 2) == 2); |
1120 |
// 6 |
||
1121 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(static_cast<char*>(buffer)[0] == str[4]); |
1122 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(static_cast<char*>(buffer)[1] == str[5]); |
1123 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->seek(file, -7, SEEK_CUR) == -1); |
1124 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->seek(file, 6, SEEK_SET) == 6); |
1125 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->seek(file, -6, SEEK_CUR) == 0); |
1126 |
} |
||
1127 |
|||
1128 |
✓✗ | 8 |
if (file != nullptr) |
1129 |
✓✗ | 8 |
file->close(file); |
1130 |
8 |
free(buffer); |
|
1131 |
✓✗✓✗ |
16 |
VirtFs::unmountZip(prefix + "test2.zip"); |
1132 |
✓✗ | 8 |
VirtFs::deinit(); |
1133 |
8 |
} |
|
1134 |
|||
1135 |
✓✗ | 10 |
TEST_CASE("VirtFs2 rwops_read3", "") |
1136 |
{ |
||
1137 |
✓✗ | 32 |
VirtFs::init("."); |
1138 |
32 |
std::string name("data/test/test.zip"); |
|
1139 |
16 |
std::string prefix; |
|
1140 |
✓✗✓✗ |
8 |
if (Files::existsLocal(name) == false) |
1141 |
✓✗ | 16 |
prefix = "../" + prefix; |
1142 |
|||
1143 |
✓✗ | 16 |
VirtFs::mountDir(prefix + "data", |
1144 |
✓✗ | 8 |
Append_false); |
1145 |
8 |
SDL_RWops *file = nullptr; |
|
1146 |
8 |
void *restrict buffer = nullptr; |
|
1147 |
|||
1148 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
56 |
SECTION("test 1") |
1149 |
{ |
||
1150 |
✓✗✓✗ |
4 |
file = VirtFs::rwopsOpenRead("test/test.txt"); |
1151 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
1152 |
#ifdef USE_SDL2 |
||
1153 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->size(file) == 23); |
1154 |
#endif // USE_SDL2 |
||
1155 |
1 |
const int fileSize = 23; |
|
1156 |
|||
1157 |
1 |
buffer = calloc(fileSize + 1, 1); |
|
1158 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->read(file, buffer, 1, fileSize) == fileSize); |
1159 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(strcmp(static_cast<char*>(buffer), |
1160 |
"test line 1\ntest line 2") == 0); |
||
1161 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == fileSize); |
1162 |
} |
||
1163 |
|||
1164 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
56 |
SECTION("test 2") |
1165 |
{ |
||
1166 |
✓✗✓✗ |
4 |
file = VirtFs::rwopsOpenRead("test\\test.txt"); |
1167 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
1168 |
#ifdef USE_SDL2 |
||
1169 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->size(file) == 23); |
1170 |
#endif // USE_SDL2 |
||
1171 |
1 |
const int fileSize = 23; |
|
1172 |
|||
1173 |
1 |
buffer = calloc(fileSize + 1, 1); |
|
1174 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->seek(file, 12, SEEK_SET) != 0); |
1175 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == 12); |
1176 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->read(file, buffer, 1, 11) == 11); |
1177 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(strcmp(static_cast<char*>(buffer), |
1178 |
"test line 2") == 0); |
||
1179 |
} |
||
1180 |
|||
1181 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
56 |
SECTION("test 3") |
1182 |
{ |
||
1183 |
✓✗✓✗ |
4 |
file = VirtFs::rwopsOpenRead("test\\/test.txt"); |
1184 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
1185 |
1 |
const int fileSize = 23; |
|
1186 |
|||
1187 |
1 |
buffer = calloc(fileSize + 1, 1); |
|
1188 |
✓✓ | 24 |
for (int f = 0; f < fileSize; f ++) |
1189 |
{ |
||
1190 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
92 |
REQUIRE(file->seek(file, f, SEEK_SET) == f); |
1191 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
92 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == f); |
1192 |
} |
||
1193 |
} |
||
1194 |
|||
1195 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
56 |
SECTION("test 4") |
1196 |
{ |
||
1197 |
✓✗✓✗ |
4 |
file = VirtFs::rwopsOpenRead("test/test.txt"); |
1198 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
1199 |
1 |
const int fileSize = 23; |
|
1200 |
1 |
const char *restrict const str = "test line 1\ntest line 2"; |
|
1201 |
1 |
buffer = calloc(fileSize + 1, 1); |
|
1202 |
✓✓ | 23 |
for (int f = 0; f < fileSize - 1; f ++) |
1203 |
{ |
||
1204 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
88 |
REQUIRE(file->read(file, buffer, 1, 1) == 1); |
1205 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
88 |
REQUIRE(static_cast<char*>(buffer)[0] == str[f]); |
1206 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
88 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == f + 1); |
1207 |
} |
||
1208 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->read(file, buffer, 1, 1) == 1); |
1209 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(static_cast<char*>(buffer)[0] == str[22]); |
1210 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == fileSize); |
1211 |
} |
||
1212 |
|||
1213 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
56 |
SECTION("test 5") |
1214 |
{ |
||
1215 |
✓✗✓✗ |
4 |
file = VirtFs::rwopsOpenRead("test///test.txt"); |
1216 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
1217 |
1 |
const int fileSize = 23; |
|
1218 |
1 |
const char *restrict const str = "test line 1\ntest line 2"; |
|
1219 |
1 |
buffer = calloc(fileSize + 1, 1); |
|
1220 |
✓✓ | 12 |
for (int f = 0; f < fileSize - 1; f += 2) |
1221 |
{ |
||
1222 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(file->read(file, buffer, 2, 1) == 1); |
1223 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
44 |
REQUIRE(static_cast<char*>(buffer)[0] == str[f]); |
1224 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
44 |
REQUIRE(static_cast<char*>(buffer)[1] == str[f + 1]); |
1225 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == f + 2); |
1226 |
} |
||
1227 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == 22); |
1228 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->read(file, buffer, 2, 1) == 0); |
1229 |
} |
||
1230 |
|||
1231 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
56 |
SECTION("test 6") |
1232 |
{ |
||
1233 |
✓✗✓✗ |
4 |
file = VirtFs::rwopsOpenRead("test\\\\test.txt"); |
1234 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
1235 |
1 |
const int fileSize = 23; |
|
1236 |
1 |
const char *restrict const str = "test line 1\ntest line 2"; |
|
1237 |
1 |
buffer = calloc(fileSize + 1, 1); |
|
1238 |
✓✓ | 12 |
for (int f = 0; f < fileSize - 1; f += 2) |
1239 |
{ |
||
1240 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(file->read(file, buffer, 1, 2) == 2); |
1241 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
44 |
REQUIRE(static_cast<char*>(buffer)[0] == str[f]); |
1242 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
44 |
REQUIRE(static_cast<char*>(buffer)[1] == str[f + 1]); |
1243 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == f + 2); |
1244 |
} |
||
1245 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == 22); |
1246 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->read(file, buffer, 1, 2) == 1); |
1247 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(static_cast<char*>(buffer)[0] == str[22]); |
1248 |
} |
||
1249 |
|||
1250 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
56 |
SECTION("test 7") |
1251 |
{ |
||
1252 |
✓✗✓✗ |
4 |
file = VirtFs::rwopsOpenRead("test//test.txt"); |
1253 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
1254 |
1 |
const int fileSize = 23; |
|
1255 |
1 |
const char *restrict const str = "test line 1\ntest line 2"; |
|
1256 |
1 |
buffer = calloc(fileSize + 1, 1); |
|
1257 |
✓✓ | 12 |
for (int f = 0; f < fileSize - 1; f += 2) |
1258 |
{ |
||
1259 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(file->read(file, buffer, 1, 2) == 2); |
1260 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(file->seek(file, -2, SEEK_CUR) == f); |
1261 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == f); |
1262 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(file->seek(file, 2, SEEK_CUR) == f + 2); |
1263 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
44 |
REQUIRE(static_cast<char*>(buffer)[0] == str[f]); |
1264 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
44 |
REQUIRE(static_cast<char*>(buffer)[1] == str[f + 1]); |
1265 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == f + 2); |
1266 |
} |
||
1267 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == 22); |
1268 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->read(file, buffer, 1, 2) == 1); |
1269 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(static_cast<char*>(buffer)[0] == str[22]); |
1270 |
} |
||
1271 |
|||
1272 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
56 |
SECTION("test 8") |
1273 |
{ |
||
1274 |
✓✗✓✗ |
4 |
file = VirtFs::rwopsOpenRead("test/test.txt"); |
1275 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(file != nullptr); |
1276 |
1 |
const int fileSize = 23; |
|
1277 |
1 |
const char *restrict const str = "test line 1\ntest line 2"; |
|
1278 |
1 |
buffer = calloc(fileSize + 1, 1); |
|
1279 |
✓✓ | 12 |
for (int f = 0; f < fileSize - 1; f += 2) |
1280 |
{ |
||
1281 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(file->seek(file, -f - 2, SEEK_END) == 23 - f - 2); |
1282 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(file->read(file, buffer, 1, 2) == 2); |
1283 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
44 |
REQUIRE(static_cast<char*>(buffer)[0] == str[23 - f - 2]); |
1284 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
44 |
REQUIRE(static_cast<char*>(buffer)[1] == str[23 - f - 2 + 1]); |
1285 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
44 |
REQUIRE(file->seek(file, 0, SEEK_CUR) == 23 - f); |
1286 |
} |
||
1287 |
// 3 |
||
1288 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->seek(file, 1, SEEK_CUR) == 4); |
1289 |
// 4 |
||
1290 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->read(file, buffer, 1, 2) == 2); |
1291 |
// 6 |
||
1292 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(static_cast<char*>(buffer)[0] == str[4]); |
1293 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(static_cast<char*>(buffer)[1] == str[5]); |
1294 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->seek(file, -7, SEEK_CUR) == -1); |
1295 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->seek(file, 6, SEEK_SET) == 6); |
1296 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(file->seek(file, -6, SEEK_CUR) == 0); |
1297 |
} |
||
1298 |
|||
1299 |
✓✗ | 8 |
if (file != nullptr) |
1300 |
✓✗ | 8 |
file->close(file); |
1301 |
8 |
free(buffer); |
|
1302 |
✓✗✓✗ |
16 |
VirtFs::unmountDir(prefix + "data"); |
1303 |
✓✗ | 8 |
VirtFs::deinit(); |
1304 |
8 |
} |
|
1305 |
|||
1306 |
✓✗ | 3 |
TEST_CASE("VirtFs2 getFiles zip1", "") |
1307 |
{ |
||
1308 |
✓✗ | 4 |
VirtFs::init("."); |
1309 |
4 |
std::string name("data/test/test.zip"); |
|
1310 |
2 |
std::string prefix; |
|
1311 |
✓✗✓✗ |
1 |
if (Files::existsLocal(name) == false) |
1312 |
✓✗ | 2 |
prefix = "../" + prefix; |
1313 |
|||
1314 |
✓✗ | 2 |
VirtFs::mountZip(prefix + "data/test/test2.zip", |
1315 |
✓✗ | 1 |
Append_false); |
1316 |
|||
1317 |
2 |
StringVect list; |
|
1318 |
✓✗✓✗ |
4 |
VirtFs::getFiles("dir", list); |
1319 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(list.size() == 2); |
1320 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(inList(list, "dye.png")); |
1321 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(inList(list, "hide.png")); |
1322 |
|||
1323 |
1 |
list.clear(); |
|
1324 |
✓✗✓✗ |
4 |
VirtFs::getFiles("dir2", list); |
1325 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(list.size() == 4); |
1326 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(inList(list, "hide.png")); |
1327 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(inList(list, "paths.xml")); |
1328 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(inList(list, "test.txt")); |
1329 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(inList(list, "units.xml")); |
1330 |
|||
1331 |
✓✗✓✗ |
2 |
VirtFs::unmountZip(prefix + "data/test/test2.zip"); |
1332 |
✓✗ | 1 |
VirtFs::deinit(); |
1333 |
1 |
} |
|
1334 |
|||
1335 |
✓✗ | 3 |
TEST_CASE("VirtFs2 getFiles zip2", "") |
1336 |
{ |
||
1337 |
✓✗ | 4 |
VirtFs::init("."); |
1338 |
4 |
std::string name("data/test/test.zip"); |
|
1339 |
2 |
std::string prefix; |
|
1340 |
✓✗✓✗ |
1 |
if (Files::existsLocal(name) == false) |
1341 |
✓✗ | 2 |
prefix = "../" + prefix; |
1342 |
|||
1343 |
✓✗✓✗ |
5 |
VirtFs::mountZip2(prefix + "data/test/test2.zip", |
1344 |
"dir", |
||
1345 |
✓✗ | 1 |
Append_false); |
1346 |
|||
1347 |
2 |
StringVect list; |
|
1348 |
✓✗✓✗ |
4 |
VirtFs::getFiles(dirSeparator, list); |
1349 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(list.size() == 2); |
1350 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(inList(list, "dye.png")); |
1351 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(inList(list, "hide.png")); |
1352 |
|||
1353 |
1 |
list.clear(); |
|
1354 |
✓✗✓✗ |
4 |
VirtFs::getFiles("1", list); |
1355 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(list.size() == 2); |
1356 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(inList(list, "file1.txt")); |
1357 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(inList(list, "test.txt")); |
1358 |
|||
1359 |
✓✗✓✗ |
5 |
VirtFs::unmountZip2(prefix + "data/test/test2.zip", |
1360 |
✓✗ | 1 |
"dir"); |
1361 |
✓✗ | 1 |
VirtFs::deinit(); |
1362 |
1 |
} |
|
1363 |
|||
1364 |
✓✗ | 3 |
TEST_CASE("VirtFs2 getDirs1", "") |
1365 |
{ |
||
1366 |
✓✗ | 4 |
VirtFs::init("."); |
1367 |
4 |
std::string name("data/test/test.zip"); |
|
1368 |
2 |
std::string prefix; |
|
1369 |
✓✗✓✗ |
1 |
if (Files::existsLocal(name) == false) |
1370 |
✓✗ | 2 |
prefix = "../" + prefix; |
1371 |
|||
1372 |
✓✗ | 2 |
VirtFs::mountZip(prefix + "data/test/test2.zip", |
1373 |
✓✗ | 1 |
Append_false); |
1374 |
|||
1375 |
2 |
StringVect list; |
|
1376 |
✓✗✓✗ |
4 |
VirtFs::getDirs("dir", list); |
1377 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(list.size() == 2); |
1378 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(inList(list, "1")); |
1379 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(inList(list, "gpl")); |
1380 |
1 |
list.clear(); |
|
1381 |
|||
1382 |
✓✗✓✗ |
4 |
VirtFs::getDirs("dir2", list); |
1383 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(list.empty()); |
1384 |
|||
1385 |
✓✗✓✗ |
2 |
VirtFs::unmountZip(prefix + "data/test/test2.zip"); |
1386 |
✓✗ | 1 |
VirtFs::deinit(); |
1387 |
1 |
} |
|
1388 |
|||
1389 |
✓✗ | 4 |
TEST_CASE("VirtFs2 getDirs2", "") |
1390 |
{ |
||
1391 |
✓✗ | 8 |
VirtFs::init("."); |
1392 |
8 |
std::string name("data/test/test.zip"); |
|
1393 |
4 |
std::string prefix; |
|
1394 |
✓✗✓✗ |
2 |
if (Files::existsLocal(name) == false) |
1395 |
✓✗ | 4 |
prefix = "../" + prefix; |
1396 |
4 |
StringVect list; |
|
1397 |
|||
1398 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
14 |
SECTION("dir1") |
1399 |
{ |
||
1400 |
✓✗ | 2 |
VirtFs::mountDir(prefix + "data/test", |
1401 |
✓✗ | 1 |
Append_false); |
1402 |
|||
1403 |
✓✗✓✗ |
4 |
VirtFs::getDirs("/", list); |
1404 |
// REQUIRE(list.size() == 2); |
||
1405 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(inList(list, "dir1")); |
1406 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(inList(list, "dir2")); |
1407 |
1 |
list.clear(); |
|
1408 |
|||
1409 |
✓✗✓✗ |
4 |
VirtFs::getDirs("dir1", list); |
1410 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(list.empty()); |
1411 |
|||
1412 |
✓✗✓✗ |
2 |
VirtFs::unmountDir(prefix + "data/test"); |
1413 |
} |
||
1414 |
|||
1415 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
14 |
SECTION("dir2") |
1416 |
{ |
||
1417 |
✓✗ | 2 |
VirtFs::mountDir(prefix + "data", |
1418 |
✓✗ | 1 |
Append_false); |
1419 |
|||
1420 |
✓✗✓✗ |
4 |
VirtFs::getDirs("sfx", list); |
1421 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(inList(list, "system")); |
1422 |
1 |
list.clear(); |
|
1423 |
|||
1424 |
✓✗✓✗ |
4 |
VirtFs::getDirs("evol", list); |
1425 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(list.size() == 2); |
1426 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(inList(list, "icons")); |
1427 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(inList(list, "images")); |
1428 |
|||
1429 |
✓✗✓✗ |
2 |
VirtFs::unmountDir(prefix + "data"); |
1430 |
} |
||
1431 |
|||
1432 |
✓✗ | 2 |
VirtFs::deinit(); |
1433 |
2 |
} |
|
1434 |
|||
1435 |
✓✗ | 3 |
TEST_CASE("VirtFs2 getDirs3", "") |
1436 |
{ |
||
1437 |
✓✗ | 4 |
VirtFs::init("."); |
1438 |
4 |
std::string name("data/test/test.zip"); |
|
1439 |
2 |
std::string prefix; |
|
1440 |
✓✗✓✗ |
1 |
if (Files::existsLocal(name) == false) |
1441 |
✓✗ | 2 |
prefix = "../" + prefix; |
1442 |
|||
1443 |
✓✗✓✗ |
5 |
VirtFs::mountZip2(prefix + "data/test/test2.zip", |
1444 |
"dir", |
||
1445 |
✓✗ | 1 |
Append_false); |
1446 |
|||
1447 |
2 |
StringVect list; |
|
1448 |
✓✗✓✗ |
4 |
VirtFs::getDirs(dirSeparator, list); |
1449 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(list.size() == 2); |
1450 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(inList(list, "1")); |
1451 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(inList(list, "gpl")); |
1452 |
1 |
list.clear(); |
|
1453 |
|||
1454 |
✓✗✓✗ |
4 |
VirtFs::getDirs("1", list); |
1455 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(list.empty()); |
1456 |
|||
1457 |
✓✗✓✗ |
5 |
VirtFs::unmountZip2(prefix + "data/test/test2.zip", |
1458 |
✓✗ | 1 |
"dir"); |
1459 |
✓✗ | 1 |
VirtFs::deinit(); |
1460 |
1 |
} |
|
1461 |
|||
1462 |
✓✗ | 3 |
TEST_CASE("VirtFs2 getDirs4", "") |
1463 |
{ |
||
1464 |
✓✗ | 4 |
VirtFs::init("."); |
1465 |
4 |
std::string name("data/test/test.zip"); |
|
1466 |
2 |
std::string prefix; |
|
1467 |
✓✗✓✗ |
1 |
if (Files::existsLocal(name) == false) |
1468 |
✓✗ | 2 |
prefix = "../" + prefix; |
1469 |
2 |
StringVect list; |
|
1470 |
|||
1471 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ |
7 |
SECTION("dir1") |
1472 |
{ |
||
1473 |
✓✗✓✗ |
5 |
VirtFs::mountDir2(prefix + "data", |
1474 |
"test", |
||
1475 |
✓✗ | 1 |
Append_false); |
1476 |
|||
1477 |
✓✗✓✗ |
4 |
VirtFs::getDirs("/", list); |
1478 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(inList(list, "dir1")); |
1479 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
7 |
REQUIRE(inList(list, "dir2")); |
1480 |
1 |
list.clear(); |
|
1481 |
|||
1482 |
✓✗✓✗ |
4 |
VirtFs::getDirs("dir1", list); |
1483 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(list.empty()); |
1484 |
|||
1485 |
✓✗✓✗ |
5 |
VirtFs::unmountDir2(prefix + "data", |
1486 |
✓✗ | 1 |
"test"); |
1487 |
} |
||
1488 |
|||
1489 |
✓✗ | 1 |
VirtFs::deinit(); |
1490 |
1 |
} |
|
1491 |
|||
1492 |
✓✗ | 3 |
TEST_CASE("VirtFs2 getFilesWithDir1", "") |
1493 |
{ |
||
1494 |
✓✗ | 4 |
VirtFs::init("."); |
1495 |
4 |
std::string name("data/test/test.zip"); |
|
1496 |
2 |
std::string prefix; |
|
1497 |
✓✗✓✗ |
1 |
if (Files::existsLocal(name) == false) |
1498 |
✓✗ | 2 |
prefix = "../" + prefix; |
1499 |
|||
1500 |
✓✗ | 2 |
VirtFs::mountZip(prefix + "data/test/test2.zip", |
1501 |
✓✗ | 1 |
Append_false); |
1502 |
|||
1503 |
2 |
StringVect list; |
|
1504 |
✓✗✓✗ |
4 |
VirtFs::getFilesWithDir("dir", list); |
1505 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(list.size() == 2); |
1506 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(inList(list, "dir", "dye.png")); |
1507 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(inList(list, "dir", "hide.png")); |
1508 |
1 |
list.clear(); |
|
1509 |
|||
1510 |
✓✗✓✗ |
4 |
VirtFs::getFilesWithDir("dir2", list); |
1511 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(list.size() == 4); |
1512 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(inList(list, "dir2", "hide.png")); |
1513 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(inList(list, "dir2", "paths.xml")); |
1514 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(inList(list, "dir2", "test.txt")); |
1515 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(inList(list, "dir2", "units.xml")); |
1516 |
1 |
list.clear(); |
|
1517 |
|||
1518 |
✓✗✓✗ |
4 |
VirtFs::getFilesWithDir(dirSeparator, list); |
1519 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(list.size() > 2); |
1520 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(inList(list, dirSeparator, "test.txt")); |
1521 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(inList(list, dirSeparator, "units.xml")); |
1522 |
1 |
list.clear(); |
|
1523 |
|||
1524 |
✓✗✓✗ |
2 |
VirtFs::unmountZip(prefix + "data/test/test2.zip"); |
1525 |
✓✗ | 1 |
VirtFs::deinit(); |
1526 |
1 |
} |
|
1527 |
|||
1528 |
✓✗ | 4 |
TEST_CASE("VirtFs2 getFilesWithDir2", "") |
1529 |
{ |
||
1530 |
✓✗ | 8 |
VirtFs::init("."); |
1531 |
8 |
std::string name("data/test/test.zip"); |
|
1532 |
4 |
std::string prefix; |
|
1533 |
✓✗✓✗ |
2 |
if (Files::existsLocal(name) == false) |
1534 |
✓✗ | 4 |
prefix = "../" + prefix; |
1535 |
4 |
StringVect list; |
|
1536 |
|||
1537 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
14 |
SECTION("dir1") |
1538 |
{ |
||
1539 |
✓✗ | 2 |
VirtFs::mountDir(prefix + "data/graphics", |
1540 |
✓✗ | 1 |
Append_false); |
1541 |
|||
1542 |
✓✗✓✗ |
4 |
VirtFs::getFilesWithDir("/", list); |
1543 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(list.size() <= 5); |
1544 |
✓✗✓✗ |
2 |
VirtFs::unmountDir(prefix + "data/graphics"); |
1545 |
} |
||
1546 |
|||
1547 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
14 |
SECTION("dir2") |
1548 |
{ |
||
1549 |
✓✗ | 2 |
VirtFs::mountDir(prefix + "data", |
1550 |
✓✗ | 1 |
Append_false); |
1551 |
|||
1552 |
✓✗✓✗ |
4 |
VirtFs::getFilesWithDir("music", list); |
1553 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(list.size() <= 5); |
1554 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(!list.empty()); |
1555 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(inList(list, "music", "keprohm.ogg")); |
1556 |
1 |
list.clear(); |
|
1557 |
|||
1558 |
✓✗✓✗ ✓✗✓✗ |
8 |
VirtFs::getFilesWithDir(pathJoin("evol", "icons"), list); |
1559 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(list.size() == 3); |
1560 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
13 |
REQUIRE(inList(list, pathJoin("evol", "icons"), "evol-client.ico")); |
1561 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
13 |
REQUIRE(inList(list, pathJoin("evol", "icons"), "evol-client.png")); |
1562 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
13 |
REQUIRE(inList(list, pathJoin("evol", "icons"), "evol-client.xpm")); |
1563 |
|||
1564 |
✓✗✓✗ |
2 |
VirtFs::unmountDir(prefix + "data"); |
1565 |
} |
||
1566 |
|||
1567 |
✓✗ | 2 |
VirtFs::deinit(); |
1568 |
2 |
} |
|
1569 |
|||
1570 |
✓✗ | 3 |
TEST_CASE("VirtFs2 getFilesWithDir3", "") |
1571 |
{ |
||
1572 |
✓✗ | 4 |
VirtFs::init("."); |
1573 |
4 |
std::string name("data/test/test.zip"); |
|
1574 |
2 |
std::string prefix; |
|
1575 |
✓✗✓✗ |
1 |
if (Files::existsLocal(name) == false) |
1576 |
✓✗ | 2 |
prefix = "../" + prefix; |
1577 |
|||
1578 |
✓✗✓✗ |
5 |
VirtFs::mountZip2(prefix + "data/test/test2.zip", |
1579 |
"dir", |
||
1580 |
✓✗ | 1 |
Append_false); |
1581 |
|||
1582 |
2 |
StringVect list; |
|
1583 |
✓✗✓✗ |
4 |
VirtFs::getFilesWithDir("1", list); |
1584 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(list.size() == 2); |
1585 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(inList(list, "1", "file1.txt")); |
1586 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(inList(list, "1", "test.txt")); |
1587 |
1 |
list.clear(); |
|
1588 |
|||
1589 |
✓✗✓✗ |
4 |
VirtFs::getFilesWithDir(dirSeparator, list); |
1590 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(list.size() == 2); |
1591 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(inList(list, dirSeparator, "dye.png")); |
1592 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(inList(list, dirSeparator, "hide.png")); |
1593 |
1 |
list.clear(); |
|
1594 |
|||
1595 |
✓✗✓✗ |
5 |
VirtFs::unmountZip2(prefix + "data/test/test2.zip", |
1596 |
✓✗ | 1 |
"dir"); |
1597 |
✓✗ | 1 |
VirtFs::deinit(); |
1598 |
1 |
} |
|
1599 |
|||
1600 |
✓✗ | 4 |
TEST_CASE("VirtFs2 getFilesWithDir4", "") |
1601 |
{ |
||
1602 |
✓✗ | 8 |
VirtFs::init("."); |
1603 |
8 |
std::string name("data/test/test.zip"); |
|
1604 |
4 |
std::string prefix; |
|
1605 |
✓✗✓✗ |
2 |
if (Files::existsLocal(name) == false) |
1606 |
✓✗ | 4 |
prefix = "../" + prefix; |
1607 |
4 |
StringVect list; |
|
1608 |
|||
1609 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
14 |
SECTION("dir1") |
1610 |
{ |
||
1611 |
✓✗✓✗ |
5 |
VirtFs::mountDir2(prefix + "data/graphics", |
1612 |
"sprites", |
||
1613 |
✓✗ | 1 |
Append_false); |
1614 |
|||
1615 |
✓✗✓✗ |
4 |
VirtFs::getFilesWithDir("/", list); |
1616 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(list.size() <= 16); |
1617 |
✓✗✓✗ |
5 |
VirtFs::unmountDir2(prefix + "data/graphics", |
1618 |
✓✗ | 1 |
"sprites"); |
1619 |
} |
||
1620 |
|||
1621 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
14 |
SECTION("dir2") |
1622 |
{ |
||
1623 |
✓✗✓✗ |
5 |
VirtFs::mountDir2(prefix + "data", |
1624 |
"test", |
||
1625 |
✓✗ | 1 |
Append_false); |
1626 |
|||
1627 |
✓✗✓✗ |
4 |
VirtFs::getFilesWithDir("dir1", list); |
1628 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(list.size() <= 6); |
1629 |
✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
4 |
REQUIRE(!list.empty()); |
1630 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(inList(list, "dir1", "file1.txt")); |
1631 |
1 |
list.clear(); |
|
1632 |
|||
1633 |
✓✗✓✗ |
5 |
VirtFs::unmountDir2(prefix + "data", |
1634 |
✓✗ | 1 |
"test"); |
1635 |
} |
||
1636 |
|||
1637 |
✓✗ | 2 |
VirtFs::deinit(); |
1638 |
✓✗✓✗ |
5 |
} |
Generated by: GCOVR (Version 3.3) |