1 #include "MallocSeekTest.h" 2 #include "cppunit/TestCaller.h" 3 #include <DataIO.h> 4 #include <stdio.h> 5 6 MallocSeekTest::MallocSeekTest(std::string name) : 7 BTestCase(name) 8 { 9 } 10 11 12 13 MallocSeekTest::~MallocSeekTest() 14 { 15 } 16 17 18 void 19 MallocSeekTest::PerformTest(void) 20 { 21 BMallocIO mem; 22 off_t err; 23 24 NextSubTest(); 25 err = mem.Seek(3, SEEK_SET); 26 CPPUNIT_ASSERT(err == 3); 27 28 NextSubTest(); 29 err = mem.Seek(3, SEEK_CUR); 30 CPPUNIT_ASSERT(err == 6); 31 32 NextSubTest(); 33 err = mem.Seek(0, SEEK_END); 34 CPPUNIT_ASSERT(err == 0); 35 36 NextSubTest(); 37 err = mem.Seek(-5, SEEK_END); 38 CPPUNIT_ASSERT(err == -5); 39 40 NextSubTest(); 41 err = mem.Seek(5, SEEK_END); 42 CPPUNIT_ASSERT(err == 5); 43 44 NextSubTest(); 45 err = mem.Seek(-20, SEEK_SET); 46 CPPUNIT_ASSERT((int)err == -20); 47 } 48 49 50 CppUnit::Test *MallocSeekTest::suite(void) 51 { 52 typedef CppUnit::TestCaller<MallocSeekTest> 53 MallocSeekTestCaller; 54 55 return(new MallocSeekTestCaller("BMallocIO::Seek Test", &MallocSeekTest::PerformTest)); 56 } 57