//============================================================================== // // Copyright (C) 2005 Dick van Oudheusden // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public // License along with this program; if not, write to the Free // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // //============================================================================== // // $Date: 2005/03/05 10:15:26 $ $Revision: 1.1 $ // //============================================================================== #include #include "ofc/config.h" #include "ofc/DBZipFile.h" #include "DInc.h" #include "DTest.h" void DBZipFile_test() { #ifdef HAVE_DBZIPFILE DBZipFile *file = [DBZipFile alloc]; STARTTEST(); [file init]; // Test for non-present files TEST(![file open :"jdflkasdfklj.dsf.bz2" :"r"]); TEST([file error] == 2); TEST(![file isOpen]); // Test file writing default strategy and level TEST([file open :"test.dat.bz2" :"w"]); TEST([file isOpen]); TEST([file writeData :"Hallo" :3]); TEST([file writeByte :75]); TEST([file writeChar :'a']); TEST([file writeDouble :3.76]); TEST([file writeLong :567890]); TEST([file writeShort :1200]); TEST([file writeLine :"going"]); TEST([file writeText :"gone\n"]); [file close]; // Test file reading TEST([file open :"test.dat.bz2" :"r"]); TEST([[file readData :3] bcompare :"Hallo" :3] == 0); TEST( [file readByte] == 75); TEST( [file readChar] == 'a'); TEST( [file readDouble] == 3.76); TEST( [file readLong] == 567890); TEST( [file readShort] == 1200); TEST([[file readLine] ccompare :"going"] == 0); TEST([[file readText] ccompare :"gone\n"] == 0); [file close]; // Test file writing with small footprint TEST([file open :"test.dat.bz2" :"w" :YES]); TEST([file isOpen]); TEST([file writeData :"Hallo" :3]); TEST([file writeByte :75]); TEST([file writeChar :'a']); TEST([file writeDouble :3.76]); TEST([file writeLong :567890]); TEST([file writeShort :1200]); TEST([file writeLine :"going"]); TEST([file writeText :"gone\n"]); [file close]; // Test file reading TEST([file open :"test.dat.bz2" :"r" :YES]); TEST([file isOpen]); TEST([[file readData :3] bcompare :"Hallo" :3] == 0); TEST( [file readByte] == 75); TEST( [file readChar] == 'a'); TEST( [file readDouble] == 3.76); TEST( [file readLong] == 567890); TEST( [file readShort] == 1200); TEST([[file readLine] ccompare :"going"] == 0); TEST([[file readText] ccompare :"gone\n"] == 0); [file close]; [file free]; STOPTEST(); #endif }