zipTest.h
Engine/source/core/util/zip/test/zipTest.h
Namespaces:
Public Defines
define
ZIPTEST_BASELINE_FILENAME() "zipUnitTestBaseline.zip"
define
ZIPTEST_WORKING_DIR() "unitTests/zip"
define
ZIPTEST_WORKING_FILENAME() "zipUnitTestWorking.zip"
define
ZIPTEST_WRITE_FILENAME() "zipUnitTest.zip"
Detailed Description
Public Defines
ZIPTEST_BASELINE_FILENAME() "zipUnitTestBaseline.zip"
ZIPTEST_WORKING_DIR() "unitTests/zip"
ZIPTEST_WORKING_FILENAME() "zipUnitTestWorking.zip"
ZIPTEST_WRITE_FILENAME() "zipUnitTest.zip"
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#include "core/stringTable.h" 25 26#ifndef _ZIPTEST_H_ 27#define _ZIPTEST_H_ 28 29namespace Zip 30{ 31 32//----------------------------------------------------------------------------- 33// 34// Things that need to be tested: 35// 36// Writing Zips: 37// Write to file that doesn't already exist 38// Write to file that we've already written to 39// Write to file that already exists, but we haven't written to 40// Attempt to open a file for write that's already open for write (should fail) 41// ** Attempt to open a file that's open for read (should fail) 42// Writing >= 5000 files to a zip 43// Writing >= 5000 files to a zip in a number of folders 44// 45// Reading Zips: 46// Open for read from file that doesn't exist (should fail) 47// Read from file that already existed in the zip 48// Read from file that we have written to the zip but not yet rebuilt 49// ** Read from file that is already open for read (should fail) 50// Read from file that is already open for write (should fail) 51// 52// Miscellaneous: 53// Opening a file in the zip as ReadWrite (should fail) 54// Enumerating files 55// Deleting files 56// ** Adding files 57// Opening Zips with zip comments 58// Opening Zips/Files with file comments 59// Opening large zips that require searching for the EOCD 60// 61// All tests should be run on zip files that are opened for read, write and readwrite 62// All tests need to be run for both forms of openArchive() 63// 64// All tests that require an existing zip file should be run on a zip created with 65// a standard zip application in addition to zip files created by this code. 66// 67// Tests involving ReadWrite mode need to be done both with and without the zip 68// file existing before the test. 69// 70// Tests marked ** are not possible to test yet as they are not supported by the 71// zip code. 72// 73// [tom, 2/2/2007] I'm using WinZip 11 to create the baseline zips. It is probably 74// worthwhile to include zips created in additional applications. 75// 76//----------------------------------------------------------------------------- 77 78// Directory relative to executable directory to use as a working directory 79#define ZIPTEST_WORKING_DIR "unitTests/zip" 80 81// The filename of the zip file that we create for writing to 82#define ZIPTEST_WRITE_FILENAME "zipUnitTest.zip" 83 84// The filename of the zip file created in a standard zip application 85#define ZIPTEST_BASELINE_FILENAME "zipUnitTestBaseline.zip" 86 87// The filename of our working copy of the above so that we don't destroy the svn copy 88#define ZIPTEST_WORKING_FILENAME "zipUnitTestWorking.zip" 89 90//----------------------------------------------------------------------------- 91// Helper Functions 92//----------------------------------------------------------------------------- 93 94inline StringTableEntry makeTestPath(const char *path) 95{ 96 char buffer[1024], dir[1024]; 97 98 Platform::makeFullPathName(ZIPTEST_WORKING_DIR, dir, sizeof(dir), Platform::getMainDotCsDir()); 99 Platform::makeFullPathName(path, buffer, sizeof(buffer), dir); 100 101 return StringTable->insert(buffer, true); 102} 103 104//----------------------------------------------------------------------------- 105 106} // end namespace Zip 107 108#endif // _ZIPTEST_H_ 109