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

neon-sunset / U8String / 6005516171

28 Aug 2023 10:17PM UTC coverage: 17.791% (-0.3%) from 18.096%
6005516171

push

github

neon-sunset
feat: add construction overloads for streams and file handles

134 of 1066 branches covered (0.0%)

Branch coverage included in aggregate %.

97 of 97 new or added lines in 3 files covered. (100.0%)

478 of 2374 relevant lines covered (20.13%)

34680.8 hits per line

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

0.0
/src/Extensions/IO/U8StreamExtensions.cs
1
namespace U8Primitives.IO;
2

3
public static class U8StreamExtensions
4
{
5
    public static U8String ReadToU8String(this Stream stream)
6
    {
7
        var length = stream.Length - stream.Position;
×
8
        if (length > int.MaxValue)
×
9
        {
10
            // TODO: EH UX
11
            ThrowHelpers.ArgumentOutOfRange();
×
12
        }
13

14
        if (length > 0)
×
15
        {
16
            // TODO: Verify correct implementation behavior
17
            var buffer = new byte[(int)length];
×
18
            var bytesRead = stream.Read(buffer);
×
19

20
            U8String.Validate(buffer.SliceUnsafe(0, bytesRead));
×
21
            return new U8String(buffer, 0, bytesRead);
×
22
        }
23

24
        return default;
×
25
    }
26

27
    public static async Task<U8String> ReadToU8StringAsync(this Stream stream, CancellationToken ct = default)
28
    {
29
        var length = stream.Length - stream.Position;
×
30
        if (length > int.MaxValue)
×
31
        {
32
            ThrowHelpers.ArgumentOutOfRange();
×
33
        }
34

35
        if (length > 0)
×
36
        {
37
            var buffer = new byte[(int)length];
×
38
            var bytesRead = await stream.ReadAsync(buffer, ct);
×
39

40
            U8String.Validate(buffer.SliceUnsafe(0, bytesRead));
×
41
            return new U8String(buffer, 0, bytesRead);
×
42
        }
43

44
        return default;
×
45
    }
×
46
}
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