From 68582f0ffdbc37ef9a46c1292071f33a071d20ca Mon Sep 17 00:00:00 2001 From: mlemanczyk Date: Sat, 16 Sep 2023 21:20:40 +0200 Subject: [PATCH] RecyclableLongList.Contains fixed to cover border cases. Failing tests fixed. --- Recyclable.Collections/RecyclableLongList.cs | 2 +- Recyclable.CollectionsTests/RecyclableLongListTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Recyclable.Collections/RecyclableLongList.cs b/Recyclable.Collections/RecyclableLongList.cs index 7f925ca..58d2d9e 100644 --- a/Recyclable.Collections/RecyclableLongList.cs +++ b/Recyclable.Collections/RecyclableLongList.cs @@ -337,7 +337,7 @@ namespace Recyclable.Collections return false; } - if (_nextItemBlockIndex == 0 || (_nextItemBlockIndex == 1 && _nextItemIndex == 0)) + if (_nextItemBlockIndex == 0 || (_nextItemIndex == 0 && _nextItemBlockIndex == 1)) { return Array.IndexOf(_memoryBlocks[0], item, 0, checked((int)_longCount)) >= 0; } diff --git a/Recyclable.CollectionsTests/RecyclableLongListTests.cs b/Recyclable.CollectionsTests/RecyclableLongListTests.cs index 0d20af0..9c74a9a 100644 --- a/Recyclable.CollectionsTests/RecyclableLongListTests.cs +++ b/Recyclable.CollectionsTests/RecyclableLongListTests.cs @@ -173,7 +173,7 @@ namespace Recyclable.CollectionsTests } // Validate - _ = list.Capacity.Should().Be(0); + _ = list.Capacity.Should().BeGreaterThanOrEqualTo(RecyclableDefaults.InitialCapacity); _ = list.LastBlockWithData.Should().Be(-1); _ = list.LongCount.Should().Be(itemsCount); _ = list.Should().BeEmpty();