mirror of
https://github.com/bkaradzic/bx.git
synced 2026-02-17 20:52:37 +01:00
Fixed bx::writeRep infinite loop on error.
This commit is contained in:
@@ -29,3 +29,27 @@ TEST_CASE("writeBE", "")
|
||||
REQUIRE(err.isOk() );
|
||||
REQUIRE(total == 4);
|
||||
}
|
||||
|
||||
TEST_CASE("writeRep", "")
|
||||
{
|
||||
uint8_t tmp[1389];
|
||||
bx::StaticMemoryBlock mb(tmp, sizeof(tmp) );
|
||||
bx::MemoryWriter writer(&mb);
|
||||
|
||||
bx::Error err;
|
||||
|
||||
int32_t total = 0;
|
||||
|
||||
total += bx::writeRep(&writer, 0xfb, BX_COUNTOF(tmp)-1, &err);
|
||||
REQUIRE(err.isOk() );
|
||||
REQUIRE(BX_COUNTOF(tmp)-1 == total);
|
||||
|
||||
total += bx::writeRep(&writer, 0xfb, 2, &err);
|
||||
REQUIRE(!err.isOk() );
|
||||
REQUIRE(BX_COUNTOF(tmp) == total);
|
||||
|
||||
for (uint32_t ii = 0; ii < BX_COUNTOF(tmp); ++ii)
|
||||
{
|
||||
REQUIRE(0xfb == tmp[ii]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user