xref: /haiku/src/tests/kits/support/bmemoryio/MallocWriteTest.cpp (revision 820dca4df6c7bf955c46e8f6521b9408f50b2900)
1 #include "MallocWriteTest.h"
2 #include "cppunit/TestCaller.h"
3 #include <DataIO.h>
4 #include <stdio.h>
5 #include <string.h>
6 
7 MallocWriteTest::MallocWriteTest(std::string name) :
8 		BTestCase(name)
9 {
10 }
11 
12 
13 
14 MallocWriteTest::~MallocWriteTest()
15 {
16 }
17 
18 
19 void
20 MallocWriteTest::PerformTest(void)
21 {
22 	const char *writeBuf = "ABCDEFG";
23 
24 	BMallocIO mem;
25 	ssize_t err;
26 
27 	NextSubTest();
28 	err = mem.Write(writeBuf, 7);
29 	CPPUNIT_ASSERT(err == 7); // Check how much data we wrote
30 
31 	NextSubTest();
32 	err = mem.WriteAt(0, writeBuf, 4);
33 	CPPUNIT_ASSERT(err == 4);
34 
35 	NextSubTest();
36 	err = mem.WriteAt(34, writeBuf, 256);
37 	CPPUNIT_ASSERT(err == 256);
38 }
39 
40 
41 CppUnit::Test *MallocWriteTest::suite(void)
42 {
43 	typedef CppUnit::TestCaller<MallocWriteTest>
44 		MallocWriteTestCaller;
45 
46 	return(new MallocWriteTestCaller("BMallocIO::Write Test", &MallocWriteTest::PerformTest));
47 }
48