Chromium Code Reviews| Index: third_party/zlib/google/zip_unittest.cc |
| diff --git a/third_party/zlib/google/zip_unittest.cc b/third_party/zlib/google/zip_unittest.cc |
| index 22e350f6a841998bc6d4aacf4a32807647b82042..44b19fa4f208220a7832cb125fafffe6ce8e8dbb 100644 |
| --- a/third_party/zlib/google/zip_unittest.cc |
| +++ b/third_party/zlib/google/zip_unittest.cc |
| @@ -13,6 +13,7 @@ |
| #include "base/files/scoped_temp_dir.h" |
| #include "base/path_service.h" |
| #include "base/strings/string_util.h" |
| +#include "base/strings/stringprintf.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include "testing/platform_test.h" |
| #include "third_party/zlib/google/zip.h" |
| @@ -302,4 +303,33 @@ TEST_F(ZipTest, ZipFiles) { |
| } |
| #endif // defined(OS_POSIX) |
| +TEST_F(ZipTest, UnzipFilesWithIncorrectSize) { |
| + base::FilePath test_data_folder; |
| + ASSERT_TRUE(GetTestDataDirectory(&test_data_folder)); |
| + |
| + // test_mismatch_size.zip contains files with names from 0.txt to 7.txt with |
| + // sizes from 0 to 7 bytes respectively, but the metadata in the zip file says |
| + // the uncompressed size is 3 bytes. The ZipReader and minizip code needs to |
| + // be clever enough to get all the data out. |
| + base::FilePath test_zip_file = |
| + test_data_folder.AppendASCII("test_mismatch_size.zip"); |
| + |
| + base::ScopedTempDir scoped_temp_dir; |
| + ASSERT_TRUE(scoped_temp_dir.CreateUniqueTempDir()); |
| + const base::FilePath& temp_dir = scoped_temp_dir.path(); |
| + |
| + ASSERT_TRUE(zip::Unzip(test_zip_file, temp_dir)); |
| + |
| + EXPECT_TRUE(base::DirectoryExists(temp_dir.AppendASCII("d"))); |
| + |
| + for (int i = 0; i < 8; i++) { |
| + SCOPED_TRACE(base::StringPrintf("<loop:%d>", static_cast<int>(i))); |
|
agl
2014/04/03 14:34:56
|i| is an int, but you're static_casting it to int
satorux1
2014/04/30 00:18:19
Yes. Please remove static_cast from here and elsew
João Eiras
2014/05/07 12:03:51
done
|
| + base::FilePath file_path = temp_dir.AppendASCII( |
| + base::StringPrintf(FILE_PATH_LITERAL("%d.txt"), static_cast<int>(i))); |
|
agl
2014/04/03 14:34:56
I don't think you want FILE_PATH_LITERAL here.
satorux1
2014/04/30 00:18:19
ditto. please address agl's comment.
João Eiras
2014/05/07 12:03:51
done
|
| + int64 file_size = -1; |
| + EXPECT_TRUE(base::GetFileSize(file_path, &file_size)); |
| + EXPECT_EQ(static_cast<int64>(i), file_size); |
| + } |
| +} |
| + |
| } // namespace |