require "spec" require "./db-cars.cr" describe "SPECDB::Common" do it "basics, 3 values" do car0 = Car.new "Corvet-0", "red", [] of String car1 = Car.new "Corvet-1", "red", [] of String car2 = Car.new "Corvet-2", "red", [] of String car3 = Car.new "Corvet-3", "red", [] of String db = SPECDB::Common(Car).new "", 3 db.data.keys.sort.should eq([] of Int32) db << car0 db.data.keys.sort.should eq([0] of Int32) db << car1 db.data.keys.sort.should eq([0, 1] of Int32) db << car2 db.data.keys.sort.should eq([0, 1, 2] of Int32) db[0] # Let's use the first value, it shouldn't be the one to be dropped. db << car3 db.data.keys.sort.should eq([0, 2, 3] of Int32) db.delete 2 db.data.keys.sort.should eq([0, 3] of Int32) db.fifo.data.should eq([3, 0] of Int32) end end