| 25 | "\0N\0\0\0G\0\0\0\0\0"; |
| 26 | |
| 27 | UNIT_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 |
| 78 | static char const zipBytes2[] = |
nothing calls this directly
no test coverage detected