< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 11
Coverable lines: 11
Total lines: 43
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
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%110%
IndexOfAnyMultiString(...)0%660%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Private.CoreLib/src/System/SearchValues/Strings/MultiStringIgnoreCaseSearchValuesFallback.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.Collections.Generic;
 5
 6namespace System.Buffers
 7{
 8    internal sealed class MultiStringIgnoreCaseSearchValuesFallback : StringSearchValuesBase
 9    {
 10        private readonly string[] _values;
 11
 012        public MultiStringIgnoreCaseSearchValuesFallback(HashSet<string> uniqueValues) : base(uniqueValues)
 13        {
 014            _values = new string[uniqueValues.Count];
 015            uniqueValues.CopyTo(_values, 0);
 016        }
 17
 18        /// <summary>
 19        /// This method is intentionally implemented in a way that checks haystack positions one at a time.
 20        /// See the description in <see cref="SpanHelpers.IndexOfAny{T}(ref T, int, ref T, int)"/>.
 21        /// </summary>
 22        internal override int IndexOfAnyMultiString(ReadOnlySpan<char> span)
 23        {
 024            string[] values = _values;
 25
 026            for (int i = 0; i < span.Length; i++)
 27            {
 028                ReadOnlySpan<char> remaining = span.Slice(i);
 29
 030                foreach (string value in values)
 31                {
 032                    if (remaining.StartsWith(value, StringComparison.OrdinalIgnoreCase))
 33                    {
 034                        return i;
 35                    }
 36                }
 37            }
 38
 039            return -1;
 40        }
 41    }
 42}
 43