@@ -308,7 +308,7 @@ namespace bx
memSet(temp, _byte, blockSize);
int32_t size = 0;
- while (0 < _size)
+ while (0 < _size && _err->isOk() )
{
int32_t bytes = write(_writer, temp, uint32_min(blockSize, _size), _err);
size += bytes;
@@ -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]);
+ }
+}