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

neon-sunset / U8String / 5980222482

25 Aug 2023 08:35PM UTC coverage: 19.654% (-0.1%) from 19.773%
5980222482

push

github

neon-sunset
feat: finish updating to new abstraction, fix invalid reference in .Move

134 of 968 branches covered (0.0%)

Branch coverage included in aggregate %.

38 of 38 new or added lines in 8 files covered. (100.0%)

479 of 2151 relevant lines covered (22.27%)

38276.27 hits per line

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

2.74
/src/U8String.Searching.cs
1
using System.Text;
2
using U8Primitives.Abstractions;
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
    // TODO: Decide whether to throw on surrogate chars here or just return false (as right now)
12
    public bool Contains(char value) => U8Searching.Contains(this, value);
1,402✔
13

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

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

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

20
    public bool Contains<T>(byte value, T comparer)
21
        where T : IU8ContainsOperator
22
    {
23
        return U8Searching.Contains(this, value, comparer);
×
24
    }
25

26
    public bool Contains<T>(char value, T comparer)
27
        where T : IU8ContainsOperator
28
    {
29
        return U8Searching.Contains(this, value, comparer);
×
30
    }
31

32
    public bool Contains<T>(Rune value, T comparer)
33
        where T : IU8ContainsOperator
34
    {
35
        return U8Searching.Contains(this, value, comparer);
×
36
    }
37

38
    public bool Contains<T>(U8String value, T comparer)
39
        where T : IU8ContainsOperator
40
    {
41
        return U8Searching.Contains(this, value, comparer);
×
42
    }
43

44
    public bool Contains<T>(ReadOnlySpan<byte> value, T comparer)
45
        where T : IU8ContainsOperator
46
    {
47
        return U8Searching.Contains(this, value, comparer);
×
48
    }
49

50
    public bool StartsWith(byte value)
51
    {
52
        var span = AsSpan();
×
53
        return span.Length > 0 && span[0] == value;
×
54
    }
55

56
    public bool StartsWith(char value) => char.IsAscii(value)
×
57
        ? StartsWith((byte)value)
×
58
        : StartsWith(U8Scalar.Create(value, checkAscii: false).AsSpan());
×
59

60
    public bool StartsWith(Rune value) => value.IsAscii
×
61
        ? StartsWith((byte)value.Value)
×
62
        : StartsWith(U8Scalar.Create(value, checkAscii: false).AsSpan());
×
63

64
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
65
    public bool StartsWith(U8String value) => AsSpan().StartsWith(value);
×
66

67
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
68
    public bool StartsWith(ReadOnlySpan<byte> value) => AsSpan().StartsWith(value);
×
69

70
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
71
    public bool StartsWith<T>(U8String value, T comparer)
72
        where T : IU8EqualityComparer
73
    {
74
        var deref = this;
×
75
        if (deref.Length >= value.Length)
×
76
        {
77
            return U8Marshal
×
78
                .Slice(deref, 0, value.Length)
×
79
                .Equals(value, comparer);
×
80
        }
81

82
        return false;
×
83
    }
84

85
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
86
    public bool EndsWith(byte value)
87
    {
88
        var span = AsSpan();
×
89
        return span.Length > 0 && span[^1] == value;
×
90
    }
91

92
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
93
    public bool EndsWith(char value) => char.IsAscii(value)
×
94
        ? EndsWith((byte)value)
×
95
        : EndsWith(U8Scalar.Create(value, checkAscii: false).AsSpan());
×
96

97
    public bool EndsWith(Rune value) => value.IsAscii
×
98
        ? EndsWith((byte)value.Value)
×
99
        : EndsWith(U8Scalar.Create(value, checkAscii: false).AsSpan());
×
100

101
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
102
    public bool EndsWith(U8String value) => AsSpan().EndsWith(value);
×
103

104
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
105
    public bool EndsWith(ReadOnlySpan<byte> value) => AsSpan().EndsWith(value);
×
106

107
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
108
    public bool EndsWith<T>(U8String value, T comparer)
109
        where T : IEqualityComparer<U8String>
110
    {
111
        var deref = this;
×
112
        if (deref.Length >= value.Length)
×
113
        {
114
            return U8Marshal
×
115
                .Slice(deref, deref.Length - value.Length)
×
116
                .Equals(value, comparer);
×
117
        }
118

119
        return false;
×
120
    }
121

122
    public int IndexOf(byte value) => U8Searching.IndexOf(this, value).Offset;
×
123

124
    public int IndexOf(char value) => U8Searching.IndexOf(this, value).Offset;
×
125

126
    public int IndexOf(Rune value) => U8Searching.IndexOf(this, value).Offset;
×
127

128
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
129
    public int IndexOf(U8String value) => U8Searching.IndexOf(this, value).Offset;
×
130

131
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
132
    public int IndexOf(ReadOnlySpan<byte> value) => U8Searching.IndexOf(this, value);
×
133

134
    public int IndexOf<T>(byte value, T comparer)
135
        where T : IU8IndexOfOperator
136
    {
137
        return U8Searching.IndexOf(this, value, comparer).Offset;
×
138
    }
139

140
    public int IndexOf<T>(char value, T comparer)
141
        where T : IU8IndexOfOperator
142
    {
143
        return U8Searching.IndexOf(this, value, comparer).Offset;
×
144
    }
145

146
    public int IndexOf<T>(Rune value, T comparer)
147
        where T : IU8IndexOfOperator
148
    {
149
        return U8Searching.IndexOf(this, value, comparer).Offset;
×
150
    }
151

152
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
153
    public int IndexOf<T>(U8String value, T comparer)
154
        where T : IU8IndexOfOperator
155
    {
156
        return U8Searching.IndexOf(this, value, comparer).Offset;
×
157
    }
158

159
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
160
    public int IndexOf<T>(ReadOnlySpan<byte> value, T comparer)
161
        where T : IU8IndexOfOperator
162
    {
163
        return U8Searching.IndexOf(this, value, comparer).Offset;
×
164
    }
165

166
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
167
    public int LastIndexOf(byte value) => AsSpan().LastIndexOf(value);
×
168

169
    public int LastIndexOf(char value)
170
    {
171
        return AsSpan().LastIndexOf(U8Scalar.Create(value).AsSpan());
×
172
    }
173

174
    public int LastIndexOf(Rune value)
175
    {
176
        return AsSpan().LastIndexOf(U8Scalar.Create(value).AsSpan());
×
177
    }
178

179
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
180
    public int LastIndexOf(U8String value) => AsSpan().LastIndexOf(value);
×
181

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