1 #include "ConstTest.h" 2 #include "cppunit/TestCaller.h" 3 #include <DataIO.h> 4 #include <stdio.h> 5 #include <string.h> 6 7 ConstTest::ConstTest(std::string name) : 8 BTestCase(name) 9 { 10 } 11 12 13 14 ConstTest::~ConstTest() 15 { 16 } 17 18 19 void 20 ConstTest::PerformTest(void) 21 { 22 const char buf[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; 23 BMemoryIO mem(buf, 10); 24 status_t err; 25 26 NextSubTest(); 27 err = mem.SetSize(4); 28 CPPUNIT_ASSERT(err == B_NOT_ALLOWED); 29 30 NextSubTest(); 31 err = mem.SetSize(20); 32 CPPUNIT_ASSERT(err == B_NOT_ALLOWED); 33 34 NextSubTest(); 35 char readBuf[10] = ""; 36 err = mem.Write(readBuf, 3); 37 CPPUNIT_ASSERT(err == B_NOT_ALLOWED); 38 CPPUNIT_ASSERT(strcmp(readBuf, "") == 0); 39 40 NextSubTest(); 41 err = mem.WriteAt(2, readBuf, 1); 42 CPPUNIT_ASSERT(err == B_NOT_ALLOWED); 43 CPPUNIT_ASSERT(strcmp(readBuf, "") == 0); 44 } 45 46 47 CppUnit::Test *ConstTest::suite(void) 48 { 49 typedef CppUnit::TestCaller<ConstTest> 50 ConstTestCaller; 51 52 return(new ConstTestCaller("BMemoryIO::Const Test", &ConstTest::PerformTest)); 53 } 54