Fixed bx::writeRep infinite loop on error.

This commit is contained in:
Бранимир Караџић
2024-04-19 10:22:28 -07:00
parent d343470738
commit e615943f98
2 changed files with 25 additions and 1 deletions

View File

@@ -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]);
}
}