< Summary

Line coverage
66%
Covered lines: 10
Uncovered lines: 5
Coverable lines: 15
Total lines: 54
Line coverage: 66.6%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%11100%
GetValues()0%220%
ContainsCore(...)100%11100%
IndexOfAny(...)100%11100%
IndexOfAnyExcept(...)100%11100%
LastIndexOfAny(...)100%11100%
LastIndexOfAnyExcept(...)100%11100%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Private.CoreLib/src/System/SearchValues/RangeByteSearchValues.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System.Runtime.CompilerServices;
 5
 6namespace System.Buffers
 7{
 8    internal sealed class RangeByteSearchValues : SearchValues<byte>
 9    {
 10        private readonly byte _lowInclusive, _highInclusive;
 11        private readonly uint _lowUint, _highMinusLow;
 12
 99913        public RangeByteSearchValues(byte lowInclusive, byte highInclusive)
 14        {
 99915            (_lowInclusive, _highInclusive) = (lowInclusive, highInclusive);
 99916            _lowUint = lowInclusive;
 99917            _highMinusLow = (uint)(highInclusive - lowInclusive);
 99918        }
 19
 20        internal override byte[] GetValues()
 21        {
 022            byte[] values = new byte[_highMinusLow + 1];
 23
 024            int low = _lowInclusive;
 025            for (int i = 0; i < values.Length; i++)
 26            {
 027                values[i] = (byte)(low + i);
 28            }
 29
 030            return values;
 31        }
 32
 33        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 34        internal override bool ContainsCore(byte value) =>
 24681935            value - _lowUint <= _highMinusLow;
 36
 37        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 38        internal override int IndexOfAny(ReadOnlySpan<byte> span) =>
 399639            span.IndexOfAnyInRange(_lowInclusive, _highInclusive);
 40
 41        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 42        internal override int IndexOfAnyExcept(ReadOnlySpan<byte> span) =>
 399643            span.IndexOfAnyExceptInRange(_lowInclusive, _highInclusive);
 44
 45        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 46        internal override int LastIndexOfAny(ReadOnlySpan<byte> span) =>
 199847            span.LastIndexOfAnyInRange(_lowInclusive, _highInclusive);
 48
 49        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 50        internal override int LastIndexOfAnyExcept(ReadOnlySpan<byte> span) =>
 199851            span.LastIndexOfAnyExceptInRange(_lowInclusive, _highInclusive);
 52    }
 53}
 54