MCPcopy Create free account
hub / github.com/comaps/comaps / UNIT_TEST

Function UNIT_TEST

libs/coding/coding_tests/zip_reader_test.cpp:27–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25 "\0N\0\0\0G\0\0\0\0\0";
26
27UNIT_TEST(ZipReaderSmoke)
28{
29 string const ZIPFILE = "smoke_test.zip";
30 {
31 FileWriter f(ZIPFILE);
32 f.Write(zipBytes, ARRAY_SIZE(zipBytes) - 1);
33 }
34
35 bool noException = true;
36 try
37 {
38 ZipFileReader r(ZIPFILE, "test.txt");
39 string s;
40 r.ReadAsString(s);
41 TEST_EQUAL(s, "Test\n", ("Invalid zip file contents"));
42 }
43 catch (exception const & e)
44 {
45 noException = false;
46 LOG(LERROR, (e.what()));
47 }
48 TEST(noException, ("Unhandled exception"));
49
50 // invalid zip
51 noException = true;
52 try
53 {
54 ZipFileReader r("some_nonexisting_filename", "test.txt");
55 }
56 catch (exception const &)
57 {
58 noException = false;
59 }
60 TEST(!noException, ());
61
62 // invalid file inside zip
63 noException = true;
64 try
65 {
66 ZipFileReader r(ZIPFILE, "test");
67 }
68 catch (exception const &)
69 {
70 noException = false;
71 }
72 TEST(!noException, ());
73
74 FileWriter::DeleteFileX(ZIPFILE);
75}
76
77/// zip file with 3 files inside: 1.txt, 2.txt, 3.ttt
78static char const zipBytes2[] =

Callers

nothing calls this directly

Calls 9

TESTFunction · 0.85
DeleteFileXFunction · 0.85
UncompressedSizeMethod · 0.80
FileReaderClass · 0.50
WriteMethod · 0.45
ReadAsStringMethod · 0.45
whatMethod · 0.45
sizeMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected