Skip to content

Commit

Permalink
Fix code style for ranges and slices
Browse files Browse the repository at this point in the history
  • Loading branch information
afxres committed May 25, 2024
1 parent 8b7043b commit a7d01dd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions code/Binary.Tests/Features/CollectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ public void NativeTypeArrayImplementation<T>(T data)
var source = Enumerable.Repeat(data, 16).ToArray();
for (var i = 0; i < source.Length; i++)
{
var values = source[0..i];
var values = source.AsSpan(0, i).ToArray();
var buffer = converter.Encode(values);
var result = converter.Decode(buffer);
Assert.Equal(i, result.Length);
Assert.Equal(values, result);
}
}
Expand Down Expand Up @@ -73,9 +74,10 @@ public void CommonTypeArrayImplementation<T>(T data)
var source = Enumerable.Repeat(data, 16).ToArray();
for (var i = 0; i < source.Length; i++)
{
var values = source[0..i];
var values = source.AsSpan(0, i).ToArray();
var buffer = converter.Encode(values);
var result = converter.Decode(buffer);
Assert.Equal(i, result.Length);
Assert.Equal(values, result);
}
}
Expand Down
4 changes: 2 additions & 2 deletions code/Binary.Tests/Features/ConverterThrowTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void DecodeNotEnoughBytes<T>(T data, int length)
var converter = this.generator.GetConverter<T>();
Assert.Equal(ConverterTypeName, converter.GetType().Name);
var origin = converter.Encode(data);
var buffer = origin[0..length];
var buffer = origin.AsSpan(0, length).ToArray();
var alpha = Assert.Throws<ArgumentException>(() => converter.Decode(buffer));
var bravo = Assert.Throws<ArgumentException>(() => converter.Decode(new ReadOnlySpan<byte>(buffer)));
Assert.Null(alpha.ParamName);
Expand All @@ -46,7 +46,7 @@ public void DecodeAutoNotEnoughBytes<T>(T data, int length)
var converter = this.generator.GetConverter<T>();
Assert.Equal(ConverterTypeName, converter.GetType().Name);
var origin = converter.Encode(data);
var buffer = origin[0..length];
var buffer = origin.AsSpan(0, length).ToArray();
var error = Assert.Throws<ArgumentException>(() =>
{
var span = new ReadOnlySpan<byte>(buffer);
Expand Down
2 changes: 1 addition & 1 deletion code/Binary.Tests/SpanLike/AdapterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private static void TestAllMethodNullOrEmptyData<T, E>(T? source)
[MemberData(nameof(StringData))]
public void ArrayAdapterTest<E>(E[] array, int start, int count)
{
TestAllMethod<E[], E>(array.AsSpan().Slice(start, count).ToArray(), count, x => x);
TestAllMethod<E[], E>(array.AsSpan(start, count).ToArray(), count, x => x);
}

[Theory(DisplayName = "Array Adapter Null Or Empty Test")]
Expand Down

0 comments on commit a7d01dd

Please sign in to comment.