tests/kits/support/bmemoryio: Fix WriteTest
This patch fixes a bug in the BMemoryIO unit tests that made them fail and adds an additional test case for read-only buffers. The failing test case invokes BMemoryIO::WriteAt() with the position parameter set to -10, which is invalid and should result in a return value of B_BAD_VALUE. And it does, but the test fails because it was testing for the return value 5, as in 5 bytes copied. An additional test case is added for read-only BMemoryIO objects. If the BMemoryIO(const void*, size_t) constructor is used then it will be marked as read-only, so writes should fail with B_NOT_ALLOWED. Change-Id: Icf4b837c77fba2be958f9d3e4b3adb18a23b037f Reviewed-on: https://review.haiku-os.org/c/haiku/+/2066 Reviewed-by: Adrien Destugues <[email protected]> Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
d3c070f2ed
commit
2c17ecf993
@@ -54,7 +54,16 @@ WriteTest::PerformTest(void)
|
||||
memset(buf, 0, 10);
|
||||
pos = mem.Position();
|
||||
err = mem.WriteAt(-10, writeBuf, 5);
|
||||
CPPUNIT_ASSERT(err == 5);
|
||||
CPPUNIT_ASSERT(err == B_BAD_VALUE);
|
||||
CPPUNIT_ASSERT(mem.Position() == pos);
|
||||
|
||||
NextSubTest();
|
||||
memset(buf, 0, 10);
|
||||
BMemoryIO read_only_mem(const_cast<const char*>(buf), 10);
|
||||
pos = read_only_mem.Position();
|
||||
err = read_only_mem.WriteAt(3, writeBuf, 2);
|
||||
CPPUNIT_ASSERT(err == B_NOT_ALLOWED);
|
||||
CPPUNIT_ASSERT(read_only_mem.Position() == pos);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user