fix(core): Updates slice with range selectors (#583)

- [X] Replaces Span slicing with range selection
- [X] Replaces string slicing with range selection
This commit is contained in:
Kamron Batman 2021-04-23 20:57:24 -07:00 • committed by GitHub
parent 9f9d990f85
commit a0893b68c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
62 changed files with 363 additions and 382 deletions

View file

@ -64,14 +64,14 @@ namespace Server.Tests.Network
var strLength = fixedLength > -1 ? Math.Min(value.Length, fixedLength) : value.Length;
var chars = value.AsSpan(0, strLength);
encoding.GetBytes(chars, buffer.Slice(offset));
encoding.GetBytes(chars, buffer[offset..]);
var reader = new CircularBufferReader(buffer.SliceToLength(firstSize), buffer.Slice(firstSize));
var reader = new CircularBufferReader(buffer[..firstSize], buffer[firstSize..]);
reader.Seek(offset, SeekOrigin.Begin);
var actual = reader.ReadString(encoding, isSafe, fixedLength);
Assert.Equal(value.Substring(0, strLength), actual);
Assert.Equal(value[..strLength], actual);
}
[Fact]
@ -82,7 +82,7 @@ namespace Server.Tests.Network
expected[1] = 0x1;
expected[2] = 0x1;
expected[3] = 0x1;
Encoding.ASCII.GetBytes("TestString", expected.Slice(4, 10));
Encoding.ASCII.GetBytes("TestString", expected[4..14]);
expected[14] = 0x0; // Null
expected[15] = 0x2;
expected[16] = 0x2;