diff --git a/AK/CircularDuplexStream.h b/AK/CircularDuplexStream.h index 0005d7bf4e..029383a13c 100644 --- a/AK/CircularDuplexStream.h +++ b/AK/CircularDuplexStream.h @@ -54,7 +54,8 @@ public: return false; } - write(bytes); + const auto nwritten = write(bytes); + ASSERT(nwritten == bytes.size()); return true; } diff --git a/AK/Tests/TestCircularDuplexStream.cpp b/AK/Tests/TestCircularDuplexStream.cpp index f784205db2..ee50939f93 100644 --- a/AK/Tests/TestCircularDuplexStream.cpp +++ b/AK/Tests/TestCircularDuplexStream.cpp @@ -60,12 +60,11 @@ TEST_CASE(overwritting_is_well_defined) for (size_t idx = 0; idx < capacity; ++idx) stream << static_cast(idx % 256); - u8 bytes[half_capacity]; - - stream >> Bytes { bytes, sizeof(bytes) }; + Array buffer; + stream >> buffer; for (size_t idx = 0; idx < half_capacity; ++idx) - EXPECT_EQ(bytes[idx], idx % 256); + EXPECT_EQ(buffer[idx], idx % 256); for (size_t idx = 0; idx < half_capacity; ++idx) stream << static_cast(idx % 256); @@ -83,31 +82,4 @@ TEST_CASE(overwritting_is_well_defined) EXPECT(stream.eof()); } -TEST_CASE(of_by_one) -{ - constexpr size_t half_capacity = 32; - constexpr size_t capacity = half_capacity * 2; - - CircularDuplexStream stream; - - for (size_t idx = 0; idx < half_capacity; ++idx) - stream << static_cast(0); - - for (size_t idx = 0; idx < half_capacity; ++idx) - stream << static_cast(1); - - stream.discard_or_error(capacity); - - for (size_t idx = 0; idx < capacity; ++idx) { - u8 byte; - stream.read({ &byte, sizeof(byte) }, capacity); - stream << byte; - - if (idx < half_capacity) - EXPECT_EQ(byte, 0); - else - EXPECT_EQ(byte, 1); - } -} - TEST_MAIN(CircularDuplexStream)