From b25167ed5d036ea364e19981c15717229d2d3b52 Mon Sep 17 00:00:00 2001 From: Joel Drapper Date: Tue, 17 Sep 2024 15:48:02 +0200 Subject: [PATCH] Update fifo.test.rb --- quickdraw/fifo.test.rb | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/quickdraw/fifo.test.rb b/quickdraw/fifo.test.rb index 864dbbfd..3c5eba68 100644 --- a/quickdraw/fifo.test.rb +++ b/quickdraw/fifo.test.rb @@ -3,9 +3,26 @@ test "expires keys" do fifo = Phlex::FIFO.new(max_bytesize: 3) - fifo["a"] = "a" - fifo["b"] = "b" - fifo["c"] = "c" + 100.times do |i| + fifo[i] = "a" + end expect(fifo.size) == 3 end + +test "reading a key" do + fifo = Phlex::FIFO.new(max_bytesize: 3) + + fifo[0] = "a" + + expect(fifo[0]) == "a" +end + +test "ignores values that are too large" do + fifo = Phlex::FIFO.new(max_bytesize: 100, max_value_bytesize: 10) + + fifo[1] = "a" * 10 + fifo[2] = "a" * 11 + + expect(fifo.size) == 1 +end