• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

neon-sunset / U8String / 6005208900

28 Aug 2023 09:36PM UTC coverage: 18.096% (-0.2%) from 18.326%
6005208900

push

github

neon-sunset
feat: Extend NativeU8String and restructure solution to account for increased line count, add roadmap draft

134 of 1050 branches covered (0.0%)

Branch coverage included in aggregate %.

1058 of 1058 new or added lines in 25 files covered. (100.0%)

478 of 2332 relevant lines covered (20.5%)

35305.41 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Implementations/Native/NativeU8String.Manipulation.cs
1
namespace U8Primitives;
2

3
public readonly unsafe partial struct NativeU8String
4
{
5
    public NativeU8String this[Range range]
6
    {
7
        get
8
        {
9
            var source = this;
×
10
            var (start, length) = range.GetOffsetAndLength((int)source._length);
×
11

12
            if ((start > 0 && U8Info.IsContinuationByte(in source._ptr[start])) || (
×
13
                length < source.Length && U8Info.IsContinuationByte(in source._ptr[start + length])))
×
14
            {
15
                // TODO: Exception message UX
16
                ThrowHelpers.InvalidSplit();
×
17
            }
18

19
            return new(_ptr + start, length);
×
20
        }
21
    }
22

23
    public NativeU8String Slice(nint start)
24
    {
25
        var source = this;
×
26
        // From ReadOnly/Span<T> Slice(int) implementation
27
        if ((nuint)start > (nuint)source.Length)
×
28
        {
29
            ThrowHelpers.ArgumentOutOfRange();
×
30
        }
31

32
        var length = source.Length - start;
×
33
        if (length > 0)
×
34
        {
35
            if (U8Info.IsContinuationByte(in source._ptr[start]))
×
36
            {
37
                ThrowHelpers.InvalidSplit();
×
38
            }
39

40
            return new(source._ptr + start, length);
×
41
        }
42

43
        return default;
×
44
    }
45

46
    public NativeU8String Slice(nint start, nint length)
47
    {
48
        var source = this;
×
49
        // From ReadOnly/Span<T> Slice(int, int) implementation
50
        if ((nuint)start + (nuint)length > (nuint)source.Length)
×
51
        {
52
            ThrowHelpers.ArgumentOutOfRange();
×
53
        }
54

55
        var result = default(NativeU8String);
×
56
        if (length > 0)
×
57
        {
58
            // TODO: If this is always null-terminated, should we skip length check?
59
            if ((start > 0 && U8Info.IsContinuationByte(in source._ptr[start])) || (
×
60
                length < source.Length && U8Info.IsContinuationByte(in source._ptr[start + length])))
×
61
            {
62
                // TODO: Exception message UX
63
                ThrowHelpers.InvalidSplit();
×
64
            }
65

66
            result = new(_ptr + start, length);
×
67
        }
68

69
        return result;
×
70
    }
71
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc