public void CanFindFirstMarkedWithOffset(int count)
        {
            if (count < 5)
            {
                return;
            }

            Span <int> span      = stackalloc int[StackAllocThreshold];
            BitHelper  bitHelper = count <= StackAllocThreshold
                ? new BitHelper(span.Slice(0, count), clear: true)
                : new BitHelper(new int[count], clear: false);

            // flag a block of bits at each end
            int end1   = count / 3;
            int start2 = end1 * 2;

            for (int i = 0; i < end1; i++)
            {
                bitHelper.MarkBit(i);
            }
            for (int i = start2; i < count; i++)
            {
                bitHelper.MarkBit(i);
            }

            Assert.Equal(0, bitHelper.FindFirstMarked());
            Assert.True(bitHelper.IsMarked(bitHelper.FindFirstMarked()));
            Assert.Equal(end1 - 1, bitHelper.FindFirstMarked(end1 - 1));
            Assert.True(bitHelper.IsMarked(bitHelper.FindFirstMarked(end1 - 1)));
            Assert.Equal(start2, bitHelper.FindFirstMarked(end1));
            Assert.True(bitHelper.IsMarked(bitHelper.FindFirstMarked(end1)));
            Assert.Equal(start2, bitHelper.FindFirstMarked(end1 + 1));
            Assert.True(bitHelper.IsMarked(bitHelper.FindFirstMarked(end1 + 1)));
            Assert.Equal(start2 + 1, bitHelper.FindFirstMarked(start2 + 1));
            Assert.True(bitHelper.IsMarked(bitHelper.FindFirstMarked(start2 + 1)));
        }
        public void CanFindFirstMarked(int count)
        {
            if (count == 0)
            {
                return;
            }

            Span <int> span      = stackalloc int[StackAllocThreshold];
            BitHelper  bitHelper = count <= StackAllocThreshold
                ? new BitHelper(span.Slice(0, count), clear: true)
                : new BitHelper(new int[count], clear: false);

            for (int i = count - 1; i >= 0; i--)
            {
                bitHelper.MarkBit(i);
                Assert.Equal(i, bitHelper.FindFirstMarked());
            }
        }