mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 23:57:44 +00:00
AK: Remove CircularDuplexStream
This commit is contained in:
parent
f15aa539be
commit
7526f9a8b7
5 changed files with 0 additions and 195 deletions
|
@ -16,7 +16,6 @@ set(AK_TEST_SOURCES
|
|||
TestChecked.cpp
|
||||
TestCircularBuffer.cpp
|
||||
TestCircularDeque.cpp
|
||||
TestCircularDuplexStream.cpp
|
||||
TestCircularQueue.cpp
|
||||
TestComplex.cpp
|
||||
TestDeprecatedString.cpp
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/CircularDuplexStream.h>
|
||||
|
||||
TEST_CASE(works_like_a_queue)
|
||||
{
|
||||
constexpr size_t capacity = 32;
|
||||
|
||||
CircularQueue<u8, capacity> queue;
|
||||
CircularDuplexStream<capacity> stream;
|
||||
|
||||
for (size_t idx = 0; idx < capacity; ++idx) {
|
||||
queue.enqueue(static_cast<u8>(idx % 256));
|
||||
stream << static_cast<u8>(idx % 256);
|
||||
}
|
||||
|
||||
for (size_t idx = 0; idx < capacity; ++idx) {
|
||||
u8 byte = 0;
|
||||
stream >> byte;
|
||||
|
||||
EXPECT_EQ(queue.dequeue(), byte);
|
||||
}
|
||||
|
||||
EXPECT(stream.eof());
|
||||
}
|
||||
|
||||
TEST_CASE(overwritting_is_well_defined)
|
||||
{
|
||||
constexpr size_t half_capacity = 16;
|
||||
constexpr size_t capacity = 2 * half_capacity;
|
||||
|
||||
CircularDuplexStream<capacity> stream;
|
||||
|
||||
for (size_t idx = 0; idx < capacity; ++idx)
|
||||
stream << static_cast<u8>(idx % 256);
|
||||
|
||||
Array<u8, half_capacity> buffer;
|
||||
stream >> buffer;
|
||||
|
||||
for (size_t idx = 0; idx < half_capacity; ++idx)
|
||||
EXPECT_EQ(buffer[idx], idx % 256);
|
||||
|
||||
for (size_t idx = 0; idx < half_capacity; ++idx)
|
||||
stream << static_cast<u8>(idx % 256);
|
||||
|
||||
for (size_t idx = 0; idx < capacity; ++idx) {
|
||||
u8 byte = 0;
|
||||
stream >> byte;
|
||||
|
||||
if (idx < half_capacity)
|
||||
EXPECT_EQ(byte, half_capacity + idx % 256);
|
||||
else
|
||||
EXPECT_EQ(byte, idx % 256 - half_capacity);
|
||||
}
|
||||
|
||||
EXPECT(stream.eof());
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue