< Summary

Information
Class: NanoRoute.Internals.DelimitedSegment
Assembly: NanoRoute.dll
File(s): /home/runner/work/nanoroute/nanoroute/Src/NanoRoute/Private/LowLevel/DelimitedSegment.cs
Line coverage
100%
Covered lines: 26
Uncovered lines: 0
Coverable lines: 26
Total lines: 55
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBlocks covered Blocks not covered
MoveNext()270

File(s)

/home/runner/work/nanoroute/nanoroute/Src/NanoRoute/Private/LowLevel/DelimitedSegment.cs

#LineLine coverage
 1/********************************************************************************
 2* DelimitedSegment.cs                                                           *
 3*                                                                               *
 4* Author: Denes Solti                                                           *
 5********************************************************************************/
 6using System;
 7
 8namespace NanoRoute.Internals
 9{
 10    internal struct DelimitedSegment(ReadOnlyMemory<char> original, char separator)
 11    {
 12        private const int DONE = -1;
 13
 14        private int _next;
 15
 16        public bool MoveNext()
 217        {
 218            if (_next is DONE)
 219            {
 220                Current = default;
 221                return false;
 22            }
 23
 224            ReadOnlySpan<char> span = original.Span;
 25
 226            while (_next < span.Length && span[_next] == separator)
 227                _next++;
 28
 229            if (_next >= span.Length)
 130            {
 131                Current = default;
 132                _next = DONE;
 133                return false;
 34            }
 35
 236            int i = span.Slice(_next).IndexOf(separator);
 237            if (i < 0)
 238            {
 239                Current = original.Slice(_next);
 240                _next = DONE;
 241            }
 42            else
 143            {
 144                Current = original.Slice(_next, i);
 145                _next += i + 1;
 146            }
 47
 248            return true;
 249        }
 50
 51        public ReadOnlyMemory<char> Current { get; private set; }
 52
 253        public readonly bool HasValue => Current.Length > 0;
 54    }
 55}

Methods/Properties

MoveNext()
HasValue()