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/direntry.h" |
||
27 |
#include "fs/virtfs/fs.h" |
||
28 |
|||
29 |
#include "utils/checkutils.h" |
||
30 |
|||
31 |
#ifndef UNITTESTS_CATCH |
||
32 |
#include <algorithm> |
||
33 |
#endif // UNITTESTS_CATCH |
||
34 |
|||
35 |
#include "debug.h" |
||
36 |
|||
37 |
✓✗ | 8 |
TEST_CASE("VirtFs1 mountZip2", "") |
38 |
{ |
||
39 |
✓✗ | 24 |
VirtFs::init("."); |
40 |
24 |
std::string name("data/test/test.zip"); |
|
41 |
12 |
std::string prefix; |
|
42 |
✓✗ | 24 |
const std::string sep = dirSeparator; |
43 |
✓✗✓✗ |
6 |
if (Files::existsLocal(name) == false) |
44 |
prefix = "../"; |
||
45 |
|||
46 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
42 |
SECTION("subDir 1") |
47 |
{ |
||
48 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
7 |
REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip", |
49 |
"dir1", |
||
50 |
Append_false)); |
||
51 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
10 |
REQUIRE(VirtFs::searchByRootInternal( |
52 |
prefix + "data" + sep + "test" + sep + "test.zip", "dir1" + sep) != |
||
53 |
nullptr); |
||
54 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
11 |
REQUIRE(VirtFs::searchByRootInternal( |
55 |
prefix + "data" + sep + "test" + sep + "test2.zip", |
||
56 |
std::string()) == nullptr); |
||
57 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
5 |
REQUIRE(VirtFs::getEntries().size() == 1); |
58 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(VirtFs::getEntries()[0]->root == |
59 |
prefix + "data" + sep + "test" + sep + "test.zip"); |
||
60 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(VirtFs::getEntries()[0]->subDir == "dir1" + sep); |
61 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip); |
62 |
} |
||
63 |
|||
64 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
42 |
SECTION("subDir 2") |
65 |
{ |
||
66 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
7 |
REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip", |
67 |
"dir1", |
||
68 |
Append_false)); |
||
69 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
7 |
REQUIRE(VirtFs::mountZip2(prefix + "data/test/test2.zip", |
70 |
"dir2", |
||
71 |
Append_false)); |
||
72 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
10 |
REQUIRE(VirtFs::searchByRootInternal( |
73 |
prefix + "data" + sep + "test" + sep + "test.zip", "dir1" + sep) != |
||
74 |
nullptr); |
||
75 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
10 |
REQUIRE(VirtFs::searchByRootInternal( |
76 |
prefix + "data" + sep + "test" + sep + "test2.zip", |
||
77 |
"dir2" + sep) != nullptr); |
||
78 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
5 |
REQUIRE(VirtFs::getEntries().size() == 2); |
79 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(VirtFs::getEntries()[0]->root == |
80 |
prefix + "data" + sep + "test" + sep + "test2.zip"); |
||
81 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip); |
82 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(VirtFs::getEntries()[0]->subDir == "dir2" + sep); |
83 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(VirtFs::getEntries()[1]->root == |
84 |
prefix + "data" + sep + "test" + sep + "test.zip"); |
||
85 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip); |
86 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(VirtFs::getEntries()[1]->subDir == "dir1" + sep); |
87 |
} |
||
88 |
|||
89 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
42 |
SECTION("subDir 3") |
90 |
{ |
||
91 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
7 |
REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip", |
92 |
"dir1", |
||
93 |
Append_true)); |
||
94 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
7 |
REQUIRE(VirtFs::mountZip2(prefix + "data/test/test2.zip", |
95 |
"dir2", |
||
96 |
Append_true)); |
||
97 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
10 |
REQUIRE(VirtFs::searchByRootInternal( |
98 |
prefix + "data" + sep + "test" + sep + "test.zip", |
||
99 |
"dir1" + sep) != nullptr); |
||
100 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
10 |
REQUIRE(VirtFs::searchByRootInternal( |
101 |
prefix + "data" + sep + "test" + sep + "test2.zip", |
||
102 |
"dir2" + sep) != nullptr); |
||
103 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
5 |
REQUIRE(VirtFs::getEntries().size() == 2); |
104 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(VirtFs::getEntries()[0]->root == |
105 |
prefix + "data" + sep + "test" + sep + "test.zip"); |
||
106 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip); |
107 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(VirtFs::getEntries()[0]->subDir == "dir1" + sep); |
108 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(VirtFs::getEntries()[1]->root == |
109 |
prefix + "data" + sep + "test" + sep + "test2.zip"); |
||
110 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip); |
111 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(VirtFs::getEntries()[1]->subDir == "dir2" + sep); |
112 |
} |
||
113 |
|||
114 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
42 |
SECTION("subDir 4") |
115 |
{ |
||
116 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
7 |
REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip", |
117 |
"dir1", |
||
118 |
Append_false)); |
||
119 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
7 |
REQUIRE(VirtFs::mountDir2(prefix + "data/test", |
120 |
"dir2", |
||
121 |
Append_false)); |
||
122 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
7 |
REQUIRE(VirtFs::mountZip2(prefix + "data/test/test2.zip", |
123 |
"dir3", |
||
124 |
Append_false)); |
||
125 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
10 |
REQUIRE(VirtFs::searchByRootInternal( |
126 |
prefix + "data" + sep + "test" + sep + "test.zip", |
||
127 |
"dir1" + sep) != nullptr); |
||
128 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
10 |
REQUIRE(VirtFs::searchByRootInternal( |
129 |
prefix + "data" + sep + "test" + sep + "test2.zip", |
||
130 |
"dir3" + sep) != nullptr); |
||
131 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
10 |
REQUIRE(VirtFs::searchByRootInternal( |
132 |
prefix + "data" + sep + "test" + sep + "", |
||
133 |
"dir2" + sep) != nullptr); |
||
134 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
5 |
REQUIRE(VirtFs::getEntries().size() == 3); |
135 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(VirtFs::getEntries()[0]->root == |
136 |
prefix + "data" + sep + "test" + sep + "test2.zip"); |
||
137 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip); |
138 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(VirtFs::getEntries()[0]->subDir == "dir3" + sep); |
139 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(VirtFs::getEntries()[1]->root == |
140 |
prefix + "data" + sep + "test" + sep + ""); |
||
141 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir); |
142 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(VirtFs::getEntries()[1]->subDir == "dir2" + sep); |
143 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(VirtFs::getEntries()[2]->root == |
144 |
prefix + "data" + sep + "test" + sep + "test.zip"); |
||
145 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip); |
146 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(VirtFs::getEntries()[2]->subDir == "dir1" + sep); |
147 |
} |
||
148 |
|||
149 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
42 |
SECTION("subDir 5") |
150 |
{ |
||
151 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
7 |
REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip", |
152 |
"dir1", |
||
153 |
Append_false)); |
||
154 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
7 |
REQUIRE(VirtFs::mountDir2(prefix + "data/test", |
155 |
"dir2", |
||
156 |
Append_false)); |
||
157 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
7 |
REQUIRE(VirtFs::mountZip2(prefix + "data/test/test2.zip", |
158 |
"dir3", |
||
159 |
Append_true)); |
||
160 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
10 |
REQUIRE(VirtFs::searchByRootInternal( |
161 |
prefix + "data" + sep + "test" + sep + "test.zip", |
||
162 |
"dir1" + sep) != nullptr); |
||
163 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
10 |
REQUIRE(VirtFs::searchByRootInternal( |
164 |
prefix + "data" + sep + "test" + sep + "test2.zip", |
||
165 |
"dir3" + sep) != nullptr); |
||
166 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
10 |
REQUIRE(VirtFs::searchByRootInternal( |
167 |
prefix + "data" + sep + "test" + sep + "", |
||
168 |
"dir2" + sep) != nullptr); |
||
169 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
5 |
REQUIRE(VirtFs::getEntries().size() == 3); |
170 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(VirtFs::getEntries()[0]->root == |
171 |
prefix + "data" + sep + "test" + sep + ""); |
||
172 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); |
173 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(VirtFs::getEntries()[0]->subDir == "dir2" + sep); |
174 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(VirtFs::getEntries()[1]->root == |
175 |
prefix + "data" + sep + "test" + sep + "test.zip"); |
||
176 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip); |
177 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(VirtFs::getEntries()[1]->subDir == "dir1" + sep); |
178 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(VirtFs::getEntries()[2]->root == |
179 |
prefix + "data" + sep + "test" + sep + "test2.zip"); |
||
180 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip); |
181 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
5 |
REQUIRE(VirtFs::getEntries()[2]->subDir == "dir3" + sep); |
182 |
} |
||
183 |
|||
184 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✓ |
42 |
SECTION("subDir 6") |
185 |
{ |
||
186 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
7 |
REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip", |
187 |
dirSeparator, |
||
188 |
Append_false)); |
||
189 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
11 |
REQUIRE(VirtFs::searchByRootInternal( |
190 |
prefix + "data" + sep + "test" + sep + "test.zip", |
||
191 |
std::string()) != nullptr); |
||
192 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
11 |
REQUIRE(VirtFs::searchByRootInternal( |
193 |
prefix + "data" + sep + "test" + sep + "test2.zip", |
||
194 |
std::string()) == nullptr); |
||
195 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
5 |
REQUIRE(VirtFs::getEntries().size() == 1); |
196 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✗✗ ✗✗ |
9 |
REQUIRE(VirtFs::getEntries()[0]->root == |
197 |
prefix + "data" + sep + "test" + sep + "test.zip"); |
||
198 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::getEntries()[0]->subDir.empty()); |
199 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗✗✗ |
4 |
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip); |
200 |
} |
||
201 |
|||
202 |
✓✗ | 6 |
VirtFs::deinit(); |
203 |
✓✗✓✗ |
9 |
} |
Generated by: GCOVR (Version 3.3) |