1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #include "mozilla/RefPtr.h"
10 extern "C" void report_mapping() { }
13 * test.zip is a basic test zip file with a central directory. It contains
14 * four entries, in the following order:
15 * "foo", "bar", "baz", "qux".
16 * The entries are going to be read out of order.
18 const char *test_entries
[] = {
19 "baz", "foo", "bar", "qux"
23 * no_central_dir.zip is a hand crafted test zip with no central directory
24 * entries. The Zip reader is expected to be able to traverse these entries
25 * if requested in order, without reading a central directory
26 * - First entry is a file "a", STOREd.
27 * - Second entry is a file "b", STOREd, using a data descriptor. CRC is
28 * unknown, but compressed and uncompressed sizes are known in the local
30 * - Third entry is a file "c", DEFLATEd, using a data descriptor. CRC,
31 * compressed and uncompressed sizes are known in the local file header.
32 * This is the kind of entry that can be found in a zip that went through
33 * zipalign if it had a data descriptor originally.
34 * - Fourth entry is a file "d", STOREd.
36 const char *no_central_dir_entries
[] = {
40 int main(int argc
, char *argv
[])
43 fprintf(stderr
, "TEST-FAIL | TestZip | Expecting the directory containing test Zips\n");
48 mozilla::RefPtr
<Zip
> z
= ZipCollection::GetZip("test.zip");
49 for (size_t i
= 0; i
< sizeof(test_entries
) / sizeof(*test_entries
); i
++) {
50 if (!z
->GetStream(test_entries
[i
], &s
)) {
51 fprintf(stderr
, "TEST-UNEXPECTED-FAIL | TestZip | test.zip: Couldn't get entry \"%s\"\n", test_entries
[i
]);
55 fprintf(stderr
, "TEST-PASS | TestZip | test.zip could be accessed fully\n");
57 z
= ZipCollection::GetZip("no_central_dir.zip");
58 for (size_t i
= 0; i
< sizeof(no_central_dir_entries
)
59 / sizeof(*no_central_dir_entries
); i
++) {
60 if (!z
->GetStream(no_central_dir_entries
[i
], &s
)) {
61 fprintf(stderr
, "TEST-UNEXPECTED-FAIL | TestZip | no_central_dir.zip: Couldn't get entry \"%s\"\n", no_central_dir_entries
[i
]);
65 fprintf(stderr
, "TEST-PASS | TestZip | no_central_dir.zip could be accessed in order\n");