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

neon-sunset / U8String / 5922049812

21 Aug 2023 04:39AM UTC coverage: 20.136% (-1.6%) from 21.736%
5922049812

push

github

neon-sunset
feat: work in progress - comparers/globalization, planning, splitters and native string prototype scaffolding

122 of 856 branches covered (14.25%)

Branch coverage included in aggregate %.

188 of 188 new or added lines in 9 files covered. (100.0%)

439 of 1930 relevant lines covered (22.75%)

26474.14 hits per line

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

1.89
/src/U8String.Searching.cs
1
using System.Text;
2

3
using U8Primitives.InteropServices;
4

5
namespace U8Primitives;
6

7
public readonly partial struct U8String
8
{
9
    public bool Contains(byte value) => U8Searching.Contains(this, value);
×
10

11
    public bool Contains(char value) => U8Searching.Contains(this, value);
×
12

13
    public bool Contains(Rune value) => U8Searching.Contains(this, value);
642✔
14

15
    public bool Contains(U8String value) => U8Searching.Contains(this, value);
×
16

17
    public bool Contains(ReadOnlySpan<byte> value) => U8Searching.Contains(this, value);
×
18

19
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
20
    public bool StartsWith(byte value)
21
    {
22
        var span = AsSpan();
×
23
        return span.Length > 0 && span[0] == value;
×
24
    }
25

26
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
27
    public bool StartsWith(char value) => char.IsAscii(value)
×
28
        ? StartsWith((byte)value)
×
29
        : StartsWith(new Rune(value));
×
30

31
    public bool StartsWith(Rune value)
32
    {
33
        return AsSpan().StartsWith(value.ToUtf8(out _));
×
34
    }
35

36
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
37
    public bool StartsWith(U8String value) => AsSpan().StartsWith(value);
×
38

39
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
40
    public bool StartsWith(ReadOnlySpan<byte> value) => AsSpan().StartsWith(value);
×
41

42
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
43
    public bool StartsWith<T>(U8String value, T comparer)
44
        where T : IEqualityComparer<U8String>
45
    {
46
        var deref = this;
×
47
        if (deref.Length >= value.Length)
×
48
        {
49
            return U8Marshal
×
50
                .Slice(deref, 0, value.Length)
×
51
                .Equals(value, comparer);
×
52
        }
53

54
        return false;
×
55
    }
56

57
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
58
    public bool EndsWith(byte value)
59
    {
60
        var span = AsSpan();
×
61
        return span.Length > 0 && span[^1] == value;
×
62
    }
63

64
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
65
    public bool EndsWith(char value) => char.IsAscii(value)
×
66
        ? EndsWith((byte)value)
×
67
        : EndsWith(new Rune(value));
×
68

69
    public bool EndsWith(Rune value)
70
    {
71
        return AsSpan().EndsWith(value.ToUtf8(out _));
×
72
    }
73

74
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
75
    public bool EndsWith(U8String value) => AsSpan().EndsWith(value);
×
76

77
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
78
    public bool EndsWith(ReadOnlySpan<byte> value) => AsSpan().EndsWith(value);
×
79

80
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
81
    public bool EndsWith<T>(U8String value, T comparer)
82
        where T : IEqualityComparer<U8String>
83
    {
84
        var deref = this;
×
85
        if (deref.Length >= value.Length)
×
86
        {
87
            return U8Marshal
×
88
                .Slice(deref, deref.Length - value.Length)
×
89
                .Equals(value, comparer);
×
90
        }
91

92
        return false;
×
93
    }
94

95
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
96
    public int IndexOf(byte value) => AsSpan().IndexOf(value);
×
97

98
    public int IndexOf(Rune value)
99
    {
100
        return AsSpan().IndexOf(value.ToUtf8(out _));
×
101
    }
102

103
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
104
    public int IndexOf(U8String value) => AsSpan().IndexOf(value);
×
105

106
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
107
    public int IndexOf(ReadOnlySpan<byte> value) => AsSpan().IndexOf(value);
×
108

109
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
110
    public int LastIndexOf(byte value) => AsSpan().LastIndexOf(value);
×
111

112
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
113
    public int LastIndexOf(Rune value)
114
    {
115
        return AsSpan().LastIndexOf(value.ToUtf8(out _));
×
116
    }
117

118
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
119
    public int LastIndexOf(U8String value) => AsSpan().LastIndexOf(value);
×
120

121
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
122
    public int LastIndexOf(ReadOnlySpan<byte> value) => AsSpan().LastIndexOf(value);
×
123
}
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

© 2026 Coveralls, Inc