diff options
author | asynts <asynts@gmail.com> | 2020-12-19 21:19:59 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-12-19 23:29:40 +0100 |
commit | 72cbca892a0bab9c2a460dfeb05fd54a897c0a5a (patch) | |
tree | c92a7123626167b8838b7d0da40e54f2a14905c4 /AK | |
parent | 71587ea241f570850d41ae04bc642a82f4bde96b (diff) | |
download | serenity-72cbca892a0bab9c2a460dfeb05fd54a897c0a5a.zip |
AK: Remove bogus test case for CircularDuplexStream.
Diffstat (limited to 'AK')
-rw-r--r-- | AK/CircularDuplexStream.h | 3 | ||||
-rw-r--r-- | AK/Tests/TestCircularDuplexStream.cpp | 34 |
2 files changed, 5 insertions, 32 deletions
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<u8>(idx % 256); - u8 bytes[half_capacity]; - - stream >> Bytes { bytes, sizeof(bytes) }; + Array<u8, half_capacity> 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<u8>(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<capacity> stream; - - for (size_t idx = 0; idx < half_capacity; ++idx) - stream << static_cast<u8>(0); - - for (size_t idx = 0; idx < half_capacity; ++idx) - stream << static_cast<u8>(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) |