Mercurial > code
diff 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 |
line wrap: on
line diff
--- a/C++/tests/Zip/main.cpp Tue Mar 31 08:49:59 2015 +0200 +++ b/C++/tests/Zip/main.cpp Tue Mar 31 09:57:37 2015 +0200 @@ -107,6 +107,23 @@ } } +TEST(Write, notexist) +{ + remove("output.zip"); + + try { + ZipArchive archive("output.zip", ZIP_CREATE); + + /* + * According to the libzip, adding a file that does not exists + * on the disk is not an error. + */ + archive.add(File("file_not_exist"), "FILE"); + } catch (const std::exception &ex) { + FAIL() << ex.what(); + } +} + /* -------------------------------------------------------- * Reading * -------------------------------------------------------- */ @@ -139,6 +156,11 @@ } } +TEST_F(ReadingTest, exists) +{ + ASSERT_TRUE(m_archive.exists("README")); +} + TEST_F(ReadingTest, read) { try {