Mercurial > code
comparison C++/tests/Zip/main.cpp @ 345:c293dbe181c0
Zip: add exists() function
Submitted by: Elias Pipping
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 31 Mar 2015 09:57:37 +0200 |
parents | 0b576ee64d45 |
children | d5ec1174b707 |
comparison
equal
deleted
inserted
replaced
344:5c74a623888c | 345:c293dbe181c0 |
---|---|
105 } catch (const std::exception &ex) { | 105 } catch (const std::exception &ex) { |
106 std::cerr << "warning: " << ex.what() << std::endl; | 106 std::cerr << "warning: " << ex.what() << std::endl; |
107 } | 107 } |
108 } | 108 } |
109 | 109 |
110 TEST(Write, notexist) | |
111 { | |
112 remove("output.zip"); | |
113 | |
114 try { | |
115 ZipArchive archive("output.zip", ZIP_CREATE); | |
116 | |
117 /* | |
118 * According to the libzip, adding a file that does not exists | |
119 * on the disk is not an error. | |
120 */ | |
121 archive.add(File("file_not_exist"), "FILE"); | |
122 } catch (const std::exception &ex) { | |
123 FAIL() << ex.what(); | |
124 } | |
125 } | |
126 | |
110 /* -------------------------------------------------------- | 127 /* -------------------------------------------------------- |
111 * Reading | 128 * Reading |
112 * -------------------------------------------------------- */ | 129 * -------------------------------------------------------- */ |
113 | 130 |
114 class ReadingTest : public testing::Test { | 131 class ReadingTest : public testing::Test { |
137 } catch (const std::exception &ex) { | 154 } catch (const std::exception &ex) { |
138 std::cerr << ex.what() << std::endl; | 155 std::cerr << ex.what() << std::endl; |
139 } | 156 } |
140 } | 157 } |
141 | 158 |
159 TEST_F(ReadingTest, exists) | |
160 { | |
161 ASSERT_TRUE(m_archive.exists("README")); | |
162 } | |
163 | |
142 TEST_F(ReadingTest, read) | 164 TEST_F(ReadingTest, read) |
143 { | 165 { |
144 try { | 166 try { |
145 auto file = m_archive.open("README"); | 167 auto file = m_archive.open("README"); |
146 auto stats = m_archive.stat("README"); | 168 auto stats = m_archive.stat("README"); |