1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-21 21:38:47 +00:00

style: use collection expression syntax where applicable

This commit is contained in:
Oliver Booth 2024-11-13 18:56:13 +00:00
parent ce18f6a475
commit bd546e6f04
Signed by: oliverbooth
GPG Key ID: 2A862C3F46178E8E
51 changed files with 260 additions and 251 deletions

View File

@ -11,7 +11,7 @@ internal static partial class ArrayTests
[Test]
public void AsReadOnly_ShouldReturnReadOnlyCollection_WhenArrayIsNotNull()
{
int[] array = {1, 2, 3};
int[] array = [1, 2, 3];
IReadOnlyCollection<int> result = array.AsReadOnly();
Assert.That(result, Is.InstanceOf<IReadOnlyCollection<int>>());
}
@ -26,7 +26,7 @@ internal static partial class ArrayTests
[Test]
public void AsReadOnly_ShouldReturnCorrectCount_WhenArrayIsNotEmpty()
{
int[] array = {1, 2, 3};
int[] array = [1, 2, 3];
IReadOnlyCollection<int> result = array.AsReadOnly();
Assert.That(result, Has.Count.EqualTo(array.Length));
}
@ -34,7 +34,7 @@ internal static partial class ArrayTests
[Test]
public void AsReadOnly_ShouldReturnEmptyCollection_WhenArrayIsEmpty()
{
int[] array = Array.Empty<int>();
int[] array = [];
IReadOnlyCollection<int> result = array.AsReadOnly();
Assert.That(result, Is.Empty);
}

View File

@ -21,7 +21,7 @@ internal static partial class ArrayTests
[Test]
public void Clear_ShouldDoNothing_WhenArrayIsEmpty()
{
int[] array = Array.Empty<int>();
int[] array = [];
array.Clear();
}

View File

@ -105,7 +105,7 @@ internal class ByteTests
Assert.Throws<ArgumentException>(() =>
{
const byte value = 0b11010100;
Span<bool> bits = stackalloc bool[0];
Span<bool> bits = [];
value.Unpack(bits);
});
}

View File

@ -126,7 +126,7 @@ internal class Int16Tests
Assert.Throws<ArgumentException>(() =>
{
const short value = 0b11010100;
Span<bool> bits = stackalloc bool[0];
Span<bool> bits = [];
value.Unpack(bits);
});
}

View File

@ -156,7 +156,7 @@ internal class Int32Tests
Assert.Throws<ArgumentException>(() =>
{
const int value = 0b11010100;
Span<bool> bits = stackalloc bool[0];
Span<bool> bits = [];
value.Unpack(bits);
});
}

View File

@ -70,7 +70,7 @@ internal class Int64Tests
{
Assert.Throws<ArgumentException>(() =>
{
Span<bool> bits = stackalloc bool[0];
Span<bool> bits = [];
0b11010100L.Unpack(bits);
});
}

View File

@ -42,7 +42,7 @@ internal class ListTests
[Test]
public void Fill_ShouldThrow_GivenExceededCount()
{
int[] array = Array.Empty<int>();
int[] array = [];
var list = new List<int>();
Assert.Throws<ArgumentOutOfRangeException>(() => array.Fill(0, 0, 1));
Assert.Throws<ArgumentOutOfRangeException>(() => list.Fill(0, 0, 1));
@ -51,7 +51,7 @@ internal class ListTests
[Test]
public void Fill_ShouldThrow_GivenNegativeCount()
{
int[] array = Array.Empty<int>();
int[] array = [];
var list = new List<int>();
Assert.Throws<ArgumentOutOfRangeException>(() => array.Fill(0, 0, -1));
Assert.Throws<ArgumentOutOfRangeException>(() => list.Fill(0, 0, -1));
@ -60,7 +60,7 @@ internal class ListTests
[Test]
public void Fill_ShouldThrow_GivenNegativeStartIndex()
{
int[] array = Array.Empty<int>();
int[] array = [];
var list = new List<int>();
Assert.Throws<ArgumentOutOfRangeException>(() => array.Fill(0, -1, 0));
Assert.Throws<ArgumentOutOfRangeException>(() => list.Fill(0, -1, 0));
@ -80,7 +80,7 @@ internal class ListTests
[Test]
public void IndexOf_ShouldReturnCorrectValue_FromStartOfList()
{
int[] array = { 0, 1, 2, 3, 4 };
int[] array = [0, 1, 2, 3, 4];
Assert.Multiple(() =>
{
Assert.That(array.IndexOf(2), Is.EqualTo(2));
@ -92,7 +92,7 @@ internal class ListTests
[Test]
public void IndexOf_ShouldReturnCorrectValue_GivenSubRange()
{
int[] array = { 0, 1, 2, 3, 4, 0 };
int[] array = [0, 1, 2, 3, 4, 0];
Assert.Multiple(() =>
{
Assert.That(array.IndexOf(0), Is.Zero);
@ -107,7 +107,7 @@ internal class ListTests
[Test]
public void IndexOf_ShouldReturnNegative1_ForEmptyList()
{
int[] array = Array.Empty<int>();
int[] array = [];
Assert.Multiple(() =>
{
Assert.That(array.IndexOf(0), Is.EqualTo(-1));
@ -131,14 +131,14 @@ internal class ListTests
[Test]
public void IndexOf_ShouldThrowArgumentOutOfRangeException_GivenNegativeCount()
{
int[] array = Array.Empty<int>();
int[] array = [];
Assert.Throws<ArgumentOutOfRangeException>(() => array.IndexOf(0, 0, -1));
}
[Test]
public void IndexOf_ShouldThrowArgumentOutOfRangeException_GivenNegativeStartIndex()
{
int[] array = Array.Empty<int>();
int[] array = [];
Assert.Multiple(() =>
{
Assert.Throws<ArgumentOutOfRangeException>(() => array.IndexOf(0, -1));
@ -149,7 +149,7 @@ internal class ListTests
[Test]
public void IndexOf_ShouldThrowArgumentOutOfRangeException_GivenInvalidStartIndexCountPair()
{
int[] array = { 0, 1, 2 };
int[] array = [0, 1, 2];
Assert.Throws<ArgumentOutOfRangeException>(() => array.IndexOf(0, 2, 4));
}
@ -233,21 +233,21 @@ internal class ListTests
[Test]
public void Slice_ShouldReturnCorrectValue_GivenStartIndex()
{
int[] array = { 0, 1, 2, 3, 4, 5 };
int[] array = [0, 1, 2, 3, 4, 5];
Assert.That(array.Slice(2).ToArray(), Is.EqualTo(new[] { 2, 3, 4, 5 }).AsCollection);
}
[Test]
public void Slice_ShouldReturnCorrectValue_GivenStartIndexAndLength()
{
int[] array = { 0, 1, 2, 3, 4, 5 };
int[] array = [0, 1, 2, 3, 4, 5];
Assert.That(array.Slice(2, 3).ToArray(), Is.EqualTo(new[] { 2, 3, 4 }).AsCollection);
}
[Test]
public void Slice_ShouldReturnEmptyList_ForEmptyList()
{
int[] array = Array.Empty<int>();
int[] array = [];
Assert.That(array.Slice(0).ToArray(), Is.EqualTo(Array.Empty<int>()).AsCollection);
Assert.That(array.Slice(0, 0).ToArray(), Is.EqualTo(Array.Empty<int>()).AsCollection);
}
@ -263,14 +263,14 @@ internal class ListTests
[Test]
public void Slice_ShouldThrowArgumentOutOfRangeException_GivenNegativeCount()
{
int[] array = Array.Empty<int>();
int[] array = [];
Assert.Throws<ArgumentOutOfRangeException>(() => array.Slice(0, -1));
}
[Test]
public void Slice_ShouldThrowArgumentOutOfRangeException_GivenNegativeStartIndex()
{
int[] array = Array.Empty<int>();
int[] array = [];
Assert.Throws<ArgumentOutOfRangeException>(() => array.Slice(-1));
Assert.Throws<ArgumentOutOfRangeException>(() => array.Slice(-1, 0));
}
@ -278,7 +278,7 @@ internal class ListTests
[Test]
public void Slice_ShouldThrowArgumentOutOfRangeException_GivenInvalidStartIndexCountPair()
{
int[] array = { 0, 1, 2 };
int[] array = [0, 1, 2];
Assert.Throws<ArgumentOutOfRangeException>(() => array.Slice(2, 4));
}

View File

@ -31,7 +31,7 @@ internal class SpanTest
[Test]
public void Count_ShouldReturn8_GivenSpanWith8MatchingElements()
{
Span<int> span = stackalloc int[16] { 1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2 };
Span<int> span = [1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2];
int count = span.Count(2);
@ -41,7 +41,7 @@ internal class SpanTest
[Test]
public void Count_ShouldReturn8_GivenReadOnlySpanWith8MatchingElements()
{
ReadOnlySpan<int> span = stackalloc int[16] { 1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2 };
ReadOnlySpan<int> span = [1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2];
int count = span.Count(2);
@ -51,7 +51,7 @@ internal class SpanTest
[Test]
public void Replace_ShouldReplaceAllElements_GivenSpanOfInt32()
{
Span<int> span = stackalloc int[16] { 1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2 };
Span<int> span = [1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2];
span.Replace(2, 4);
Assert.That(span.ToArray(), Is.EqualTo(new[] { 1, 4, 3, 4, 5, 4, 7, 4, 9, 4, 11, 4, 13, 4, 15, 4 }));
}
@ -59,7 +59,7 @@ internal class SpanTest
[Test]
public void Replace_ShouldReplaceAllElements_GivenSpanOfChar()
{
Span<char> chars = stackalloc char[12] { 'H', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!' };
Span<char> chars = ['H', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!'];
chars.Replace('l', 'w');
Assert.That("Hewwo worwd!".ToCharArray(), Is.EqualTo(chars.ToArray()).AsCollection);
}
@ -67,7 +67,7 @@ internal class SpanTest
[Test]
public void Replace_ShouldDoNothing_GivenSpanWithNoMatchingElements()
{
Span<int> span = stackalloc int[16] { 1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2 };
Span<int> span = [1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2];
span.Replace(4, 8);
Assert.That(span.ToArray(), Is.EqualTo(new[] { 1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2 }));
}

View File

@ -12,7 +12,7 @@ internal class SpanTest
{
Assert.Multiple(() =>
{
ReadOnlySpan<EnumByte> span = stackalloc EnumByte[1] {EnumByte.B};
ReadOnlySpan<EnumByte> span = [EnumByte.B];
Assert.That(span.Contains(EnumByte.A), Is.False);
Assert.That(span.Contains(EnumByte.C), Is.False);
});
@ -23,7 +23,7 @@ internal class SpanTest
{
Assert.Multiple(() =>
{
ReadOnlySpan<EnumInt16> span = stackalloc EnumInt16[1] {EnumInt16.B};
ReadOnlySpan<EnumInt16> span = [EnumInt16.B];
Assert.That(span.Contains(EnumInt16.A), Is.False);
Assert.That(span.Contains(EnumInt16.C), Is.False);
});
@ -34,7 +34,7 @@ internal class SpanTest
{
Assert.Multiple(() =>
{
ReadOnlySpan<EnumInt32> span = stackalloc EnumInt32[1] {EnumInt32.B};
ReadOnlySpan<EnumInt32> span = [EnumInt32.B];
Assert.That(span.Contains(EnumInt32.A), Is.False);
Assert.That(span.Contains(EnumInt32.C), Is.False);
});
@ -45,7 +45,7 @@ internal class SpanTest
{
Assert.Multiple(() =>
{
ReadOnlySpan<EnumInt64> span = stackalloc EnumInt64[1] {EnumInt64.B};
ReadOnlySpan<EnumInt64> span = [EnumInt64.B];
Assert.That(span.Contains(EnumInt64.A), Is.False);
Assert.That(span.Contains(EnumInt64.C), Is.False);
@ -55,7 +55,7 @@ internal class SpanTest
[Test]
public void Contains_ShouldReturnTrue_GivenReadOnlySpanWithMatchingElements_UsingByteEnum()
{
ReadOnlySpan<EnumByte> span = stackalloc EnumByte[1] {EnumByte.B};
ReadOnlySpan<EnumByte> span = [EnumByte.B];
Assert.That(span.Contains(EnumByte.B));
}
@ -63,7 +63,7 @@ internal class SpanTest
[Test]
public void Contains_ShouldReturnTrue_GivenReadOnlySpanWithMatchingElements_UsingInt16Enum()
{
ReadOnlySpan<EnumInt16> span = stackalloc EnumInt16[1] {EnumInt16.B};
ReadOnlySpan<EnumInt16> span = [EnumInt16.B];
Assert.That(span.Contains(EnumInt16.B));
}
@ -71,7 +71,7 @@ internal class SpanTest
[Test]
public void Contains_ShouldReturnTrue_GivenReadOnlySpanWithMatchingElements_UsingInt32Enum()
{
ReadOnlySpan<EnumInt32> span = stackalloc EnumInt32[1] {EnumInt32.B};
ReadOnlySpan<EnumInt32> span = [EnumInt32.B];
Assert.That(span.Contains(EnumInt32.B));
}
@ -79,7 +79,7 @@ internal class SpanTest
[Test]
public void Contains_ShouldReturnTrue_GivenReadOnlySpanWithMatchingElements_UsingInt64Enum()
{
ReadOnlySpan<EnumInt64> span = stackalloc EnumInt64[1] {EnumInt64.B};
ReadOnlySpan<EnumInt64> span = [EnumInt64.B];
Assert.That(span.Contains(EnumInt64.B));
}
@ -89,7 +89,7 @@ internal class SpanTest
{
Assert.Multiple(() =>
{
Span<EnumByte> span = stackalloc EnumByte[1] {EnumByte.B};
Span<EnumByte> span = [EnumByte.B];
Assert.That(span.Contains(EnumByte.A), Is.False);
Assert.That(span.Contains(EnumByte.C), Is.False);
@ -99,7 +99,7 @@ internal class SpanTest
[Test]
public void Contains_ShouldReturnFalse_GivenSpanWithNoMatchingElements_UsingInt16Enum()
{
Span<EnumInt16> span = stackalloc EnumInt16[1] {EnumInt16.B};
Span<EnumInt16> span = [EnumInt16.B];
Assert.That(span.Contains(EnumInt16.A), Is.False);
Assert.That(span.Contains(EnumInt16.C), Is.False);
@ -108,7 +108,7 @@ internal class SpanTest
[Test]
public void Contains_ShouldReturnFalse_GivenSpanWithNoMatchingElements_UsingInt32Enum()
{
Span<EnumInt32> span = stackalloc EnumInt32[1] {EnumInt32.B};
Span<EnumInt32> span = [EnumInt32.B];
Assert.That(span.Contains(EnumInt32.A), Is.False);
Assert.That(span.Contains(EnumInt32.C), Is.False);
@ -117,7 +117,7 @@ internal class SpanTest
[Test]
public void Contains_ShouldReturnFalse_GivenSpanWithNoMatchingElements_UsingInt64Enum()
{
Span<EnumInt64> span = stackalloc EnumInt64[1] {EnumInt64.B};
Span<EnumInt64> span = [EnumInt64.B];
Assert.That(span.Contains(EnumInt64.A), Is.False);
Assert.That(span.Contains(EnumInt64.C), Is.False);
@ -126,7 +126,7 @@ internal class SpanTest
[Test]
public void Contains_ShouldReturnTrue_GivenSpanWithMatchingElements_UsingByteEnum()
{
Span<EnumByte> span = stackalloc EnumByte[1] {EnumByte.B};
Span<EnumByte> span = [EnumByte.B];
Assert.That(span.Contains(EnumByte.B));
}
@ -134,7 +134,7 @@ internal class SpanTest
[Test]
public void Contains_ShouldReturnTrue_GivenSpanWithMatchingElements_UsingInt16Enum()
{
Span<EnumInt16> span = stackalloc EnumInt16[1] {EnumInt16.B};
Span<EnumInt16> span = [EnumInt16.B];
Assert.That(span.Contains(EnumInt16.B));
}
@ -142,7 +142,7 @@ internal class SpanTest
[Test]
public void Contains_ShouldReturnTrue_GivenSpanWithMatchingElements_UsingInt32Enum()
{
Span<EnumInt32> span = stackalloc EnumInt32[1] {EnumInt32.B};
Span<EnumInt32> span = [EnumInt32.B];
Assert.That(span.Contains(EnumInt32.B));
}
@ -150,7 +150,7 @@ internal class SpanTest
[Test]
public void Contains_ShouldReturnTrue_GivenSpanWithMatchingElements_UsingInt64Enum()
{
Span<EnumInt64> span = stackalloc EnumInt64[1] {EnumInt64.B};
Span<EnumInt64> span = [EnumInt64.B];
Assert.That(span.Contains(EnumInt64.B));
}
@ -199,7 +199,7 @@ internal class SpanTest
public void PackByteInternal_Fallback_ShouldReturnCorrectByte_GivenReadOnlySpan_Using()
{
const byte expected = 0b00110011;
ReadOnlySpan<bool> span = stackalloc bool[8] {true, true, false, false, true, true, false, false};
ReadOnlySpan<bool> span = [true, true, false, false, true, true, false, false];
byte actual = span.PackByteInternal_Fallback();
@ -215,7 +215,7 @@ internal class SpanTest
}
const byte expected = 0b00110011;
ReadOnlySpan<bool> span = stackalloc bool[8] {true, true, false, false, true, true, false, false};
ReadOnlySpan<bool> span = [true, true, false, false, true, true, false, false];
byte actual = span.PackByteInternal_Sse2();
@ -225,7 +225,7 @@ internal class SpanTest
[Test]
public void PackInt16_ShouldReturnSameAsPackByte_WhenSpanHasLength8()
{
ReadOnlySpan<bool> span = stackalloc bool[8] {true, true, false, false, true, true, false, false};
ReadOnlySpan<bool> span = [true, true, false, false, true, true, false, false];
short expected = span.PackByte();
short actual = span.PackInt16();
@ -237,10 +237,10 @@ internal class SpanTest
public void PackInt16Internal_Fallback_ShouldReturnCorrectInt16_GivenReadOnlySpan()
{
const short expected = 0b00101101_11010100;
ReadOnlySpan<bool> span = stackalloc bool[16]
{
false, false, true, false, true, false, true, true, true, false, true, true, false, true, false, false,
};
ReadOnlySpan<bool> span =
[
false, false, true, false, true, false, true, true, true, false, true, true, false, true, false, false
];
short actual = span.PackInt16Internal_Fallback();
@ -256,10 +256,10 @@ internal class SpanTest
}
const short expected = 0b00101101_11010100;
ReadOnlySpan<bool> span = stackalloc bool[16]
{
false, false, true, false, true, false, true, true, true, false, true, true, false, true, false, false,
};
ReadOnlySpan<bool> span =
[
false, false, true, false, true, false, true, true, true, false, true, true, false, true, false, false
];
short actual = span.PackInt16Internal_Sse2();
@ -270,11 +270,11 @@ internal class SpanTest
public void PackInt32Internal_Fallback_ShouldReturnCorrectInt32_GivenReadOnlySpan()
{
const int expected = 0b01010101_10101010_01010101_10101010;
ReadOnlySpan<bool> span = stackalloc bool[32]
{
ReadOnlySpan<bool> span =
[
false, true, false, true, false, true, false, true, true, false, true, false, true, false, true, false, false,
true, false, true, false, true, false, true, true, false, true, false, true, false, true, false,
};
true, false, true, false, true, false, true, true, false, true, false, true, false, true, false
];
int actual = span.PackInt32Internal_Fallback();
@ -290,11 +290,11 @@ internal class SpanTest
}
const int expected = 0b01010101_10101010_01010101_10101010;
ReadOnlySpan<bool> span = stackalloc bool[32]
{
ReadOnlySpan<bool> span =
[
false, true, false, true, false, true, false, true, true, false, true, false, true, false, true, false, false,
true, false, true, false, true, false, true, true, false, true, false, true, false, true, false,
};
true, false, true, false, true, false, true, true, false, true, false, true, false, true, false
];
int actual = span.PackInt32Internal_Sse2();
@ -310,11 +310,11 @@ internal class SpanTest
}
const int expected = 0b01010101_10101010_01010101_10101010;
ReadOnlySpan<bool> span = stackalloc bool[32]
{
ReadOnlySpan<bool> span =
[
false, true, false, true, false, true, false, true, true, false, true, false, true, false, true, false, false,
true, false, true, false, true, false, true, true, false, true, false, true, false, true, false,
};
true, false, true, false, true, false, true, true, false, true, false, true, false, true, false
];
int actual = span.PackInt32Internal_Avx2();
@ -324,7 +324,7 @@ internal class SpanTest
[Test]
public void PackInt32_ShouldReturnSameAsPackByte_WhenSpanHasLength8_UsingReadOnlySpan()
{
ReadOnlySpan<bool> span = stackalloc bool[8] {true, true, false, false, true, true, false, false};
ReadOnlySpan<bool> span = [true, true, false, false, true, true, false, false];
int expected = span.PackByte();
int actual = span.PackInt32();
@ -335,7 +335,7 @@ internal class SpanTest
[Test]
public void PackInt32_ShouldReturnSameAsPackByte_WhenSpanHasLength8_UsingSpan()
{
Span<bool> span = stackalloc bool[8] {true, true, false, false, true, true, false, false};
Span<bool> span = [true, true, false, false, true, true, false, false];
int expected = span.PackByte();
int actual = span.PackInt32();
@ -346,10 +346,10 @@ internal class SpanTest
[Test]
public void PackInt32_ShouldReturnSameAsPackInt16_WhenSpanHasLength16_UsingReadOnlySpan()
{
ReadOnlySpan<bool> span = stackalloc bool[16]
{
false, false, true, false, true, false, true, true, true, false, true, true, false, true, false, false,
};
ReadOnlySpan<bool> span =
[
false, false, true, false, true, false, true, true, true, false, true, true, false, true, false, false
];
int expected = span.PackInt16();
int actual = span.PackInt32();
@ -360,10 +360,10 @@ internal class SpanTest
[Test]
public void PackInt32_ShouldReturnSameAsPackInt16_WhenSpanHasLength16_UsingSpan()
{
Span<bool> span = stackalloc bool[16]
{
false, false, true, false, true, false, true, true, true, false, true, true, false, true, false, false,
};
Span<bool> span =
[
false, false, true, false, true, false, true, true, true, false, true, true, false, true, false, false
];
int expected = span.PackInt16();
int actual = span.PackInt32();
@ -375,13 +375,13 @@ internal class SpanTest
public void PackInt64_ShouldReturnCorrectInt64_GivenReadOnlySpan()
{
const long expected = 0b01010101_11010110_01101001_11010110_00010010_10010111_00101100_10100101;
ReadOnlySpan<bool> span = stackalloc bool[64]
{
ReadOnlySpan<bool> span =
[
true, false, true, false, false, true, false, true, false, false, true, true, false, true, false, false, true,
true, true, false, true, false, false, true, false, true, false, false, true, false, false, false, false, true,
true, false, true, false, true, true, true, false, false, true, false, true, true, false, false, true, true,
false, true, false, true, true, true, false, true, false, true, false, true, false,
};
false, true, false, true, true, true, false, true, false, true, false, true, false
];
long actual = span.PackInt64();
@ -392,13 +392,13 @@ internal class SpanTest
public void PackInt64_ShouldReturnCorrectInt64_GivenSpan()
{
const long expected = 0b01010101_11010110_01101001_11010110_00010010_10010111_00101100_10100101;
Span<bool> span = stackalloc bool[64]
{
Span<bool> span =
[
true, false, true, false, false, true, false, true, false, false, true, true, false, true, false, false, true,
true, true, false, true, false, false, true, false, true, false, false, true, false, false, false, false, true,
true, false, true, false, true, true, true, false, false, true, false, true, true, false, false, true, true,
false, true, false, true, true, true, false, true, false, true, false, true, false,
};
false, true, false, true, true, true, false, true, false, true, false, true, false
];
long actual = span.PackInt64();
@ -408,7 +408,7 @@ internal class SpanTest
[Test]
public void PackInt64_ShouldReturnSameAsPackByte_WhenSpanHasLength8_UsingReadOnlySpan()
{
ReadOnlySpan<bool> span = stackalloc bool[8] {true, true, false, false, true, true, false, false};
ReadOnlySpan<bool> span = [true, true, false, false, true, true, false, false];
long expected = span.PackByte();
long actual = span.PackInt64();
@ -419,7 +419,7 @@ internal class SpanTest
[Test]
public void PackInt64_ShouldReturnSameAsPackByte_WhenSpanHasLength8_UsingSpan()
{
Span<bool> span = stackalloc bool[8] {true, true, false, false, true, true, false, false};
Span<bool> span = [true, true, false, false, true, true, false, false];
long expected = span.PackByte();
long actual = span.PackInt64();
@ -430,10 +430,10 @@ internal class SpanTest
[Test]
public void PackInt64_ShouldReturnSameAsPackInt16_WhenSpanHasLength16_UsingReadOnlySpan()
{
ReadOnlySpan<bool> span = stackalloc bool[16]
{
false, false, true, false, true, false, true, true, true, false, true, true, false, true, false, false,
};
ReadOnlySpan<bool> span =
[
false, false, true, false, true, false, true, true, true, false, true, true, false, true, false, false
];
long expected = span.PackInt16();
long actual = span.PackInt64();
@ -444,10 +444,10 @@ internal class SpanTest
[Test]
public void PackInt64_ShouldReturnSameAsPackInt16_WhenSpanHasLength16_UsingSpan()
{
Span<bool> span = stackalloc bool[16]
{
false, false, true, false, true, false, true, true, true, false, true, true, false, true, false, false,
};
Span<bool> span =
[
false, false, true, false, true, false, true, true, true, false, true, true, false, true, false, false
];
long expected = span.PackInt16();
long actual = span.PackInt64();
@ -458,11 +458,11 @@ internal class SpanTest
[Test]
public void PackInt64_ShouldReturnSameAsPackInt32_WhenSpanHasLength16_UsingReadOnlySpan()
{
ReadOnlySpan<bool> span = stackalloc bool[32]
{
ReadOnlySpan<bool> span =
[
false, true, false, true, false, true, false, true, true, false, true, false, true, false, true, false, false,
true, false, true, false, true, false, true, true, false, true, false, true, false, true, false,
};
true, false, true, false, true, false, true, true, false, true, false, true, false, true, false
];
long expected = span.PackInt32();
long actual = span.PackInt64();
@ -473,11 +473,11 @@ internal class SpanTest
[Test]
public void PackInt64_ShouldReturnSameAsPackInt32_WhenSpanHasLength16_UsingSpan()
{
Span<bool> span = stackalloc bool[32]
{
Span<bool> span =
[
false, true, false, true, false, true, false, true, true, false, true, false, true, false, true, false, false,
true, false, true, false, true, false, true, true, false, true, false, true, false, true, false,
};
true, false, true, false, true, false, true, true, false, true, false, true, false, true, false
];
long expected = span.PackInt32();
long actual = span.PackInt64();
@ -489,7 +489,7 @@ internal class SpanTest
public void PackInt64_ShouldFallbackAndReturnCorrectValue_GivenNonPowerOfTwoLength_UsingReadOnlySpan()
{
const long expected = 0b00000000_00000000_00000000_00000000_00000000_00000000_00000001_01010011;
ReadOnlySpan<bool> span = stackalloc bool[10] {true, true, false, false, true, false, true, false, true, false};
ReadOnlySpan<bool> span = [true, true, false, false, true, false, true, false, true, false];
long actual = span.PackInt64();
@ -500,7 +500,7 @@ internal class SpanTest
public void PackInt64_ShouldFallbackAndReturnCorrectValue_GivenNonPowerOfTwoLength_UsingSpan()
{
const long expected = 0b00000000_00000000_00000000_00000000_00000000_00000000_00000001_01010011;
Span<bool> span = stackalloc bool[10] {true, true, false, false, true, false, true, false, true, false};
Span<bool> span = [true, true, false, false, true, false, true, false, true, false];
long actual = span.PackInt64();

View File

@ -12,7 +12,7 @@ internal class PolygonFTests
public void AddVertices_ShouldAddVertices()
{
var polygon = PolygonF.Empty;
polygon.AddVertices(new[] {new PointF(1, 2), new PointF(3, 4)});
polygon.AddVertices([new PointF(1, 2), new PointF(3, 4)]);
Assert.That(polygon.VertexCount, Is.EqualTo(2));
// assert that the empty polygon was not modified
@ -39,7 +39,7 @@ internal class PolygonFTests
public void ClearVertices_ShouldClearVertices()
{
var polygon = PolygonF.Empty;
polygon.AddVertices(new[] {new Vector2(1, 2), new Vector2(3, 4)});
polygon.AddVertices([new Vector2(1, 2), new Vector2(3, 4)]);
Assert.That(polygon.VertexCount, Is.EqualTo(2));
// assert that the empty polygon was not modified
@ -52,8 +52,8 @@ internal class PolygonFTests
[Test]
public void Constructor_ShouldPopulateVertices_GivenPolygon()
{
var pointPolygon = new PolygonF(new[] {new PointF(1, 2), new PointF(3, 4)});
var vectorPolygon = new PolygonF(new[] {new Vector2(1, 2), new Vector2(3, 4)});
var pointPolygon = new PolygonF([new PointF(1, 2), new PointF(3, 4)]);
var vectorPolygon = new PolygonF([new Vector2(1, 2), new Vector2(3, 4)]);
Assert.That(pointPolygon.VertexCount, Is.EqualTo(2));
Assert.That(vectorPolygon.VertexCount, Is.EqualTo(2));
@ -77,7 +77,7 @@ internal class PolygonFTests
public void CopyConstructor_ShouldCopyVertices_GivenPolygon()
{
var first = PolygonF.Empty;
first.AddVertices(new[] {new PointF(1, 2), new PointF(3, 4)});
first.AddVertices([new PointF(1, 2), new PointF(3, 4)]);
var second = new PolygonF(first);
Assert.That(first.VertexCount, Is.EqualTo(2));

View File

@ -11,7 +11,7 @@ internal class PolygonTests
public void AddVertices_ShouldAddVertices()
{
var polygon = Polygon.Empty;
polygon.AddVertices(new[] {new Point(1, 2), new Point(3, 4)});
polygon.AddVertices([new Point(1, 2), new Point(3, 4)]);
Assert.That(polygon.VertexCount, Is.EqualTo(2));
// assert that the empty polygon was not modified
@ -30,7 +30,7 @@ internal class PolygonTests
public void ClearVertices_ShouldClearVertices()
{
var polygon = Polygon.Empty;
polygon.AddVertices(new[] {new Point(1, 2), new Point(3, 4)});
polygon.AddVertices([new Point(1, 2), new Point(3, 4)]);
Assert.That(polygon.VertexCount, Is.EqualTo(2));
// assert that the empty polygon was not modified
@ -43,7 +43,7 @@ internal class PolygonTests
[Test]
public void Constructor_ShouldPopulateVertices_GivenPolygon()
{
var pointPolygon = new Polygon(new[] {new Point(1, 2), new Point(3, 4)});
var pointPolygon = new Polygon([new Point(1, 2), new Point(3, 4)]);
Assert.That(pointPolygon.VertexCount, Is.EqualTo(2));
}
@ -59,7 +59,7 @@ internal class PolygonTests
public void CopyConstructor_ShouldCopyVertices_GivenPolygon()
{
var first = Polygon.Empty;
first.AddVertices(new[] {new Point(1, 2), new Point(3, 4)});
first.AddVertices([new Point(1, 2), new Point(3, 4)]);
var second = new Polygon(first);
Assert.That(first.VertexCount, Is.EqualTo(2));

View File

@ -11,7 +11,7 @@ internal class PolyhedronTests
public void AddVertices_ShouldAddVertices()
{
var polyhedron = Polyhedron.Empty;
polyhedron.AddVertices(new[] {new Vector3(1, 2, 3), new Vector3(4, 5, 6)});
polyhedron.AddVertices([new Vector3(1, 2, 3), new Vector3(4, 5, 6)]);
Assert.Multiple(() =>
{
@ -34,7 +34,7 @@ internal class PolyhedronTests
public void ClearVertices_ShouldClearVertices()
{
var polyhedron = Polyhedron.Empty;
polyhedron.AddVertices(new[] {new Vector3(1, 2, 3), new Vector3(4, 5, 6)});
polyhedron.AddVertices([new Vector3(1, 2, 3), new Vector3(4, 5, 6)]);
Assert.Multiple(() =>
{
Assert.That(polyhedron.VertexCount, Is.EqualTo(2));
@ -50,7 +50,7 @@ internal class PolyhedronTests
[Test]
public void Constructor_ShouldPopulateVertices_GivenPolyhedron()
{
var polyhedron = new Polyhedron(new[] {new Vector3(1, 2, 3), new Vector3(4, 5, 6)});
var polyhedron = new Polyhedron([new Vector3(1, 2, 3), new Vector3(4, 5, 6)]);
Assert.That(polyhedron.VertexCount, Is.EqualTo(2));
}
@ -65,7 +65,7 @@ internal class PolyhedronTests
public void CopyConstructor_ShouldCopyVertices_GivenPolyhedron()
{
var first = Polyhedron.Empty;
first.AddVertices(new[] {new Vector3(1, 2, 3), new Vector3(4, 5, 6)});
first.AddVertices([new Vector3(1, 2, 3), new Vector3(4, 5, 6)]);
var second = new Polyhedron(first);
Assert.Multiple(() =>

View File

@ -26,7 +26,7 @@ internal class BooleanTests
public void TryWriteBytes_ReturnsFalse_GivenSmallSpan()
{
const bool value = true;
Span<byte> buffer = stackalloc byte[0];
Span<byte> buffer = [];
Assert.That(value.TryWriteBytes(buffer), Is.False);
}
}

View File

@ -29,7 +29,7 @@ internal class ByteTests
public void TryWriteBytes_ReturnsFalse_GivenSmallSpan()
{
const byte value = 0x0F;
Span<byte> buffer = stackalloc byte[0];
Span<byte> buffer = [];
Assert.That(value.TryWriteBytes(buffer), Is.False);
}
}

View File

@ -58,7 +58,7 @@ internal class DoubleTests
public void TryWriteBigEndian_ReturnsFalse_GivenSmallSpan()
{
const double value = 42.5;
Span<byte> buffer = stackalloc byte[0];
Span<byte> buffer = [];
Assert.That(value.TryWriteBigEndianBytes(buffer), Is.False);
}
@ -66,7 +66,7 @@ internal class DoubleTests
public void TryWriteLittleEndian_RReturnsFalse_GivenSmallSpan()
{
const double value = 42.5;
Span<byte> buffer = stackalloc byte[0];
Span<byte> buffer = [];
Assert.That(value.TryWriteLittleEndianBytes(buffer), Is.False);
}
}

View File

@ -21,10 +21,10 @@ internal class FileInfoTests
// SHA-1
byte[] expectedHash =
{
[
0x0A, 0x4D, 0x55, 0xA8, 0xD7, 0x78, 0xE5, 0x02, 0x2F, 0xAB, 0x70, 0x19, 0x77, 0xC5, 0xD8, 0x40, 0xBB, 0xC4, 0x86,
0xD0
};
];
try
{
@ -51,10 +51,10 @@ internal class FileInfoTests
// SHA-1
byte[] expectedHash =
{
[
0x0A, 0x4D, 0x55, 0xA8, 0xD7, 0x78, 0xE5, 0x02, 0x2F, 0xAB, 0x70, 0x19, 0x77, 0xC5, 0xD8, 0x40, 0xBB, 0xC4, 0x86,
0xD0
};
];
try
{

View File

@ -11,7 +11,7 @@ internal class Int16Tests
{
const short value = 0x0F;
byte[] expected = { 0x0F, 0 };
byte[] expected = [0x0F, 0];
byte[] actual = value.GetLittleEndianBytes();
Assert.That(actual, Is.EqualTo(expected).AsCollection);
}
@ -21,7 +21,7 @@ internal class Int16Tests
{
const short value = 0x0F;
byte[] expected = { 0, 0x0F };
byte[] expected = [0, 0x0F];
byte[] actual = value.GetBigEndianBytes();
Assert.That(actual, Is.EqualTo(expected).AsCollection);
}
@ -31,7 +31,7 @@ internal class Int16Tests
{
const short value = 0x0F;
byte[] expected = { 0x0F, 0 };
byte[] expected = [0x0F, 0];
Assert.Multiple(() =>
{
Span<byte> actual = stackalloc byte[2];
@ -45,7 +45,7 @@ internal class Int16Tests
{
const short value = 0x0F;
byte[] expected = { 0, 0x0F };
byte[] expected = [0, 0x0F];
Assert.Multiple(() =>
{
Span<byte> actual = stackalloc byte[2];
@ -58,7 +58,7 @@ internal class Int16Tests
public void TryWriteLittleEndian_RReturnsFalse_GivenSmallSpan()
{
const short value = 0x0F;
Span<byte> buffer = stackalloc byte[0];
Span<byte> buffer = [];
Assert.That(value.TryWriteLittleEndianBytes(buffer), Is.False);
}
@ -66,7 +66,7 @@ internal class Int16Tests
public void TryWriteBigEndian_ReturnsFalse_GivenSmallSpan()
{
const short value = 0x0F;
Span<byte> buffer = stackalloc byte[0];
Span<byte> buffer = [];
Assert.That(value.TryWriteBigEndianBytes(buffer), Is.False);
}
}

View File

@ -58,7 +58,7 @@ internal class Int32Tests
public void TryWriteBigEndian_ReturnsFalse_GivenSmallSpan()
{
const int value = 0x0F;
Span<byte> buffer = stackalloc byte[0];
Span<byte> buffer = [];
Assert.That(value.TryWriteBigEndianBytes(buffer), Is.False);
}
@ -66,7 +66,7 @@ internal class Int32Tests
public void TryWriteLittleEndian_RReturnsFalse_GivenSmallSpan()
{
const int value = 0x0F;
Span<byte> buffer = stackalloc byte[0];
Span<byte> buffer = [];
Assert.That(value.TryWriteLittleEndianBytes(buffer), Is.False);
}
}

View File

@ -11,7 +11,7 @@ internal class Int64Tests
{
const long value = 0x0F;
byte[] expected = { 0x0F, 0, 0, 0, 0, 0, 0, 0 };
byte[] expected = [0x0F, 0, 0, 0, 0, 0, 0, 0];
byte[] actual = value.GetLittleEndianBytes();
Assert.That(actual, Is.EqualTo(expected).AsCollection);
}
@ -21,7 +21,7 @@ internal class Int64Tests
{
const long value = 0x0F;
byte[] expected = { 0, 0, 0, 0, 0, 0, 0, 0x0F };
byte[] expected = [0, 0, 0, 0, 0, 0, 0, 0x0F];
byte[] actual = value.GetBigEndianBytes();
Assert.That(actual, Is.EqualTo(expected).AsCollection);
}
@ -31,7 +31,7 @@ internal class Int64Tests
{
const long value = 0x0F;
byte[] expected = { 0x0F, 0, 0, 0, 0, 0, 0, 0 };
byte[] expected = [0x0F, 0, 0, 0, 0, 0, 0, 0];
Assert.Multiple(() =>
{
Span<byte> actual = stackalloc byte[8];
@ -45,7 +45,7 @@ internal class Int64Tests
{
const long value = 0x0F;
byte[] expected = { 0, 0, 0, 0, 0, 0, 0, 0x0F };
byte[] expected = [0, 0, 0, 0, 0, 0, 0, 0x0F];
Assert.Multiple(() =>
{
Span<byte> actual = stackalloc byte[8];
@ -58,7 +58,7 @@ internal class Int64Tests
public void TryWriteLittleEndian_RReturnsFalse_GivenSmallSpan()
{
const long value = 0x0F;
Span<byte> buffer = stackalloc byte[0];
Span<byte> buffer = [];
Assert.That(value.TryWriteLittleEndianBytes(buffer), Is.False);
}
@ -66,7 +66,7 @@ internal class Int64Tests
public void TryWriteBigEndian_ReturnsFalse_GivenSmallSpan()
{
const long value = 0x0F;
Span<byte> buffer = stackalloc byte[0];
Span<byte> buffer = [];
Assert.That(value.TryWriteBigEndianBytes(buffer), Is.False);
}
}

View File

@ -29,7 +29,7 @@ internal class SByteTests
public void TryWriteBytes_ReturnsFalse_GivenSmallSpan()
{
const sbyte value = 0x0F;
Span<byte> buffer = stackalloc byte[0];
Span<byte> buffer = [];
Assert.That(value.TryWriteBytes(buffer), Is.False);
}
}

View File

@ -58,7 +58,7 @@ internal class SingleTests
public void TryWriteBigEndian_ReturnsFalse_GivenSmallSpan()
{
const float value = 42.5f;
Span<byte> buffer = stackalloc byte[0];
Span<byte> buffer = [];
Assert.That(value.TryWriteBigEndianBytes(buffer), Is.False);
}
@ -66,7 +66,7 @@ internal class SingleTests
public void TryWriteLittleEndian_RReturnsFalse_GivenSmallSpan()
{
const float value = 42.5f;
Span<byte> buffer = stackalloc byte[0];
Span<byte> buffer = [];
Assert.That(value.TryWriteLittleEndianBytes(buffer), Is.False);
}
}

View File

@ -40,10 +40,10 @@ internal partial class StreamTests
public void ReadDecimalBigEndian_ShouldReadBigEndian()
{
using var stream = new MemoryStream();
ReadOnlySpan<byte> bytes = stackalloc byte[]
{
ReadOnlySpan<byte> bytes =
[
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x68
};
];
stream.Write(bytes);
stream.Position = 0;
@ -61,10 +61,10 @@ internal partial class StreamTests
public void ReadDecimalLittleEndian_ShouldWriteLittleEndian()
{
using var stream = new MemoryStream();
ReadOnlySpan<byte> bytes = stackalloc byte[]
{
ReadOnlySpan<byte> bytes =
[
0x68, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00
};
];
stream.Write(bytes);
stream.Position = 0;

View File

@ -40,7 +40,7 @@ internal partial class StreamTests
public void ReadDoubleBigEndian_ShouldReadBigEndian()
{
using var stream = new MemoryStream();
ReadOnlySpan<byte> bytes = stackalloc byte[] { 0x40, 0x7A, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00 };
ReadOnlySpan<byte> bytes = [0x40, 0x7A, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00];
stream.Write(bytes);
stream.Position = 0;
@ -55,7 +55,7 @@ internal partial class StreamTests
public void ReadDoubleLittleEndian_ShouldWriteLittleEndian()
{
using var stream = new MemoryStream();
ReadOnlySpan<byte> bytes = stackalloc byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x7A, 0x40 };
ReadOnlySpan<byte> bytes = [0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x7A, 0x40];
stream.Write(bytes);
stream.Position = 0;

View File

@ -40,7 +40,7 @@ internal partial class StreamTests
public void ReadInt16BigEndian_ShouldReadBigEndian()
{
using var stream = new MemoryStream();
ReadOnlySpan<byte> bytes = stackalloc byte[] { 0x01, 0xA4 };
ReadOnlySpan<byte> bytes = [0x01, 0xA4];
stream.Write(bytes);
stream.Position = 0;
@ -55,7 +55,7 @@ internal partial class StreamTests
public void ReadInt16LittleEndian_ShouldReadLittleEndian()
{
using var stream = new MemoryStream();
ReadOnlySpan<byte> bytes = stackalloc byte[] { 0xA4, 0x01 };
ReadOnlySpan<byte> bytes = [0xA4, 0x01];
stream.Write(bytes);
stream.Position = 0;

View File

@ -40,7 +40,7 @@ internal partial class StreamTests
public void ReadInt32BigEndian_ShouldReadBigEndian()
{
using var stream = new MemoryStream();
ReadOnlySpan<byte> bytes = stackalloc byte[] { 0x00, 0x00, 0x01, 0xA4 };
ReadOnlySpan<byte> bytes = [0x00, 0x00, 0x01, 0xA4];
stream.Write(bytes);
stream.Position = 0;
@ -55,7 +55,7 @@ internal partial class StreamTests
public void ReadInt32LittleEndian_ShouldReadLittleEndian()
{
using var stream = new MemoryStream();
ReadOnlySpan<byte> bytes = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00 };
ReadOnlySpan<byte> bytes = [0xA4, 0x01, 0x00, 0x00];
stream.Write(bytes);
stream.Position = 0;

View File

@ -37,7 +37,7 @@ internal partial class StreamTests
public void ReadInt64BigEndian_ShouldReadBigEndian()
{
using var stream = new MemoryStream();
ReadOnlySpan<byte> bytes = stackalloc byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA4 };
ReadOnlySpan<byte> bytes = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA4];
stream.Write(bytes);
stream.Position = 0;
@ -52,7 +52,7 @@ internal partial class StreamTests
public void ReadInt64LittleEndian_ShouldWriteLittleEndian()
{
using var stream = new MemoryStream();
ReadOnlySpan<byte> bytes = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
ReadOnlySpan<byte> bytes = [0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
stream.Write(bytes);
stream.Position = 0;

View File

@ -40,7 +40,7 @@ internal partial class StreamTests
public void ReadSingleBigEndian_ShouldReadBigEndian()
{
using var stream = new MemoryStream();
ReadOnlySpan<byte> bytes = stackalloc byte[] { 0x43, 0xD2, 0x00, 0x00 };
ReadOnlySpan<byte> bytes = [0x43, 0xD2, 0x00, 0x00];
stream.Write(bytes);
stream.Position = 0;
@ -55,7 +55,7 @@ internal partial class StreamTests
public void ReadSingleLittleEndian_ShouldReadLittleEndian()
{
using var stream = new MemoryStream();
ReadOnlySpan<byte> bytes = stackalloc byte[] { 0x00, 0x00, 0xD2, 0x43 };
ReadOnlySpan<byte> bytes = [0x00, 0x00, 0xD2, 0x43];
stream.Write(bytes);
stream.Position = 0;

View File

@ -40,7 +40,7 @@ internal partial class StreamTests
public void ReadUInt16BigEndian_ShouldReadBigEndian()
{
using var stream = new MemoryStream();
ReadOnlySpan<byte> bytes = stackalloc byte[] { 0x01, 0xA4 };
ReadOnlySpan<byte> bytes = [0x01, 0xA4];
stream.Write(bytes);
stream.Position = 0;
@ -55,7 +55,7 @@ internal partial class StreamTests
public void ReadUInt16LittleEndian_ShouldReadLittleEndian()
{
using var stream = new MemoryStream();
ReadOnlySpan<byte> bytes = stackalloc byte[] { 0xA4, 0x01 };
ReadOnlySpan<byte> bytes = [0xA4, 0x01];
stream.Write(bytes);
stream.Position = 0;

View File

@ -40,7 +40,7 @@ internal partial class StreamTests
public void ReadUInt32BigEndian_ShouldReadBigEndian()
{
using var stream = new MemoryStream();
ReadOnlySpan<byte> bytes = stackalloc byte[] { 0x00, 0x00, 0x01, 0xA4 };
ReadOnlySpan<byte> bytes = [0x00, 0x00, 0x01, 0xA4];
stream.Write(bytes);
stream.Position = 0;
@ -55,7 +55,7 @@ internal partial class StreamTests
public void ReadUInt32LittleEndian_ShouldReadLittleEndian()
{
using var stream = new MemoryStream();
ReadOnlySpan<byte> bytes = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00 };
ReadOnlySpan<byte> bytes = [0xA4, 0x01, 0x00, 0x00];
stream.Write(bytes);
stream.Position = 0;

View File

@ -40,7 +40,7 @@ internal partial class StreamTests
public void ReadUInt64BigEndian_ShouldReadBigEndian()
{
using var stream = new MemoryStream();
ReadOnlySpan<byte> bytes = stackalloc byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA4 };
ReadOnlySpan<byte> bytes = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA4];
stream.Write(bytes);
stream.Position = 0;
@ -55,7 +55,7 @@ internal partial class StreamTests
public void ReadUInt64LittleEndian_ShouldWriteLittleEndian()
{
using var stream = new MemoryStream();
ReadOnlySpan<byte> bytes = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
ReadOnlySpan<byte> bytes = [0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
stream.Write(bytes);
stream.Position = 0;

View File

@ -48,10 +48,10 @@ internal partial class StreamTests
Assert.Multiple(() =>
{
Span<byte> actual = stackalloc byte[16];
ReadOnlySpan<byte> expected = stackalloc byte[]
{
ReadOnlySpan<byte> expected =
[
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x68
};
];
int read = stream.Read(actual);
Trace.WriteLine(string.Join(' ', actual.ToArray()));
@ -71,10 +71,10 @@ internal partial class StreamTests
Assert.Multiple(() =>
{
Span<byte> actual = stackalloc byte[16];
ReadOnlySpan<byte> expected = stackalloc byte[]
{
ReadOnlySpan<byte> expected =
[
0x68, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00
};
];
int read = stream.Read(actual);
Trace.WriteLine(string.Join(", ", actual.ToArray().Select(b => $"0x{b:X2}")));

View File

@ -47,7 +47,7 @@ internal partial class StreamTests
Assert.Multiple(() =>
{
Span<byte> actual = stackalloc byte[8];
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x40, 0x7A, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00 };
ReadOnlySpan<byte> expected = [0x40, 0x7A, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00];
int read = stream.Read(actual);
Assert.That(read, Is.EqualTo(8));
@ -66,7 +66,7 @@ internal partial class StreamTests
Assert.Multiple(() =>
{
Span<byte> actual = stackalloc byte[8];
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x7A, 0x40 };
ReadOnlySpan<byte> expected = [0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x7A, 0x40];
int read = stream.Read(actual);
Assert.That(read, Is.EqualTo(8));

View File

@ -47,7 +47,7 @@ internal partial class StreamTests
Assert.Multiple(() =>
{
Span<byte> actual = stackalloc byte[2];
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x01, 0xA4 };
ReadOnlySpan<byte> expected = [0x01, 0xA4];
int read = stream.Read(actual);
Assert.That(read, Is.EqualTo(2));
@ -66,7 +66,7 @@ internal partial class StreamTests
Assert.Multiple(() =>
{
Span<byte> actual = stackalloc byte[2];
ReadOnlySpan<byte> expected = stackalloc byte[] { 0xA4, 0x01 };
ReadOnlySpan<byte> expected = [0xA4, 0x01];
int read = stream.Read(actual);
Assert.That(read, Is.EqualTo(2));

View File

@ -47,7 +47,7 @@ internal partial class StreamTests
Assert.Multiple(() =>
{
Span<byte> actual = stackalloc byte[4];
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x00, 0x00, 0x01, 0xA4 };
ReadOnlySpan<byte> expected = [0x00, 0x00, 0x01, 0xA4];
int read = stream.Read(actual);
Assert.That(read, Is.EqualTo(4));
@ -66,7 +66,7 @@ internal partial class StreamTests
Assert.Multiple(() =>
{
Span<byte> actual = stackalloc byte[4];
ReadOnlySpan<byte> expected = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00 };
ReadOnlySpan<byte> expected = [0xA4, 0x01, 0x00, 0x00];
int read = stream.Read(actual);
Assert.That(read, Is.EqualTo(4));

View File

@ -47,7 +47,7 @@ internal partial class StreamTests
Assert.Multiple(() =>
{
Span<byte> actual = stackalloc byte[8];
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA4 };
ReadOnlySpan<byte> expected = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA4];
int read = stream.Read(actual);
Assert.That(read, Is.EqualTo(8));
@ -66,7 +66,7 @@ internal partial class StreamTests
Assert.Multiple(() =>
{
Span<byte> actual = stackalloc byte[8];
ReadOnlySpan<byte> expected = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
ReadOnlySpan<byte> expected = [0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
int read = stream.Read(actual);
Assert.That(read, Is.EqualTo(8));

View File

@ -47,7 +47,7 @@ internal partial class StreamTests
Assert.Multiple(() =>
{
Span<byte> actual = stackalloc byte[4];
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x43, 0xD2, 0x00, 0x00 };
ReadOnlySpan<byte> expected = [0x43, 0xD2, 0x00, 0x00];
int read = stream.Read(actual);
Assert.That(read, Is.EqualTo(4));
@ -66,7 +66,7 @@ internal partial class StreamTests
Assert.Multiple(() =>
{
Span<byte> actual = stackalloc byte[4];
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x00, 0x00, 0xD2, 0x43 };
ReadOnlySpan<byte> expected = [0x00, 0x00, 0xD2, 0x43];
int read = stream.Read(actual);
Assert.That(read, Is.EqualTo(4));

View File

@ -47,7 +47,7 @@ internal partial class StreamTests
Assert.Multiple(() =>
{
Span<byte> actual = stackalloc byte[2];
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x01, 0xA4 };
ReadOnlySpan<byte> expected = [0x01, 0xA4];
int read = stream.Read(actual);
Assert.That(read, Is.EqualTo(2));
@ -66,7 +66,7 @@ internal partial class StreamTests
Assert.Multiple(() =>
{
Span<byte> actual = stackalloc byte[2];
ReadOnlySpan<byte> expected = stackalloc byte[] { 0xA4, 0x01 };
ReadOnlySpan<byte> expected = [0xA4, 0x01];
int read = stream.Read(actual);
Assert.That(read, Is.EqualTo(2));

View File

@ -47,7 +47,7 @@ internal partial class StreamTests
Assert.Multiple(() =>
{
Span<byte> actual = stackalloc byte[4];
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x00, 0x00, 0x01, 0xA4 };
ReadOnlySpan<byte> expected = [0x00, 0x00, 0x01, 0xA4];
int read = stream.Read(actual);
Assert.That(read, Is.EqualTo(4));
@ -66,7 +66,7 @@ internal partial class StreamTests
Assert.Multiple(() =>
{
Span<byte> actual = stackalloc byte[4];
ReadOnlySpan<byte> expected = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00 };
ReadOnlySpan<byte> expected = [0xA4, 0x01, 0x00, 0x00];
int read = stream.Read(actual);
Assert.That(read, Is.EqualTo(4));

View File

@ -47,7 +47,7 @@ internal partial class StreamTests
Assert.Multiple(() =>
{
Span<byte> actual = stackalloc byte[8];
ReadOnlySpan<byte> expected = stackalloc byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA4 };
ReadOnlySpan<byte> expected = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA4];
int read = stream.Read(actual);
Assert.That(read, Is.EqualTo(8));
@ -66,7 +66,7 @@ internal partial class StreamTests
Assert.Multiple(() =>
{
Span<byte> actual = stackalloc byte[8];
ReadOnlySpan<byte> expected = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
ReadOnlySpan<byte> expected = [0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
int read = stream.Read(actual);
Assert.That(read, Is.EqualTo(8));

View File

@ -14,10 +14,10 @@ internal partial class StreamTests
{
// SHA-1
byte[] expectedHash =
{
[
0x0A, 0x4D, 0x55, 0xA8, 0xD7, 0x78, 0xE5, 0x02, 0x2F, 0xAB, 0x70, 0x19, 0x77, 0xC5, 0xD8, 0x40, 0xBB, 0xC4, 0x86,
0xD0
};
];
using var stream = new MemoryStream();
stream.Write(Encoding.UTF8.GetBytes("Hello World"));
@ -42,10 +42,10 @@ internal partial class StreamTests
{
// SHA-1
byte[] expectedHash =
{
[
0x0A, 0x4D, 0x55, 0xA8, 0xD7, 0x78, 0xE5, 0x02, 0x2F, 0xAB, 0x70, 0x19, 0x77, 0xC5, 0xD8, 0x40, 0xBB, 0xC4, 0x86,
0xD0
};
];
using var stream = new MemoryStream();
stream.Write(Encoding.UTF8.GetBytes("Hello World"));
@ -160,7 +160,7 @@ internal partial class StreamTests
protected override byte[] HashFinal()
{
return Array.Empty<byte>();
return [];
}
public override void Initialize()
@ -176,7 +176,7 @@ internal partial class StreamTests
protected override byte[] HashFinal()
{
return Array.Empty<byte>();
return [];
}
public override void Initialize()

View File

@ -10,7 +10,7 @@ internal class UInt16Tests
public void GetLittleEndianBytes_ReturnsCorrectValue_WithEndianness()
{
const ushort value = 0x0F;
byte[] expected = { 0x0F, 0 };
byte[] expected = [0x0F, 0];
byte[] actual = value.GetLittleEndianBytes();
Assert.That(actual, Is.EqualTo(expected).AsCollection);
@ -20,7 +20,7 @@ internal class UInt16Tests
public void GetBigEndianBytes_ReturnsCorrectValue_WithEndianness()
{
const ushort value = 0x0F;
byte[] expected = { 0, 0x0F };
byte[] expected = [0, 0x0F];
byte[] actual = value.GetBigEndianBytes();
Assert.That(actual, Is.EqualTo(expected).AsCollection);
@ -30,7 +30,7 @@ internal class UInt16Tests
public void TryWriteLittleEndian_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan()
{
const ushort value = 0x0F;
byte[] expected = { 0x0F, 0 };
byte[] expected = [0x0F, 0];
Assert.Multiple(() =>
{
@ -44,7 +44,7 @@ internal class UInt16Tests
public void TryWriteBigEndian_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan()
{
const ushort value = 0x0F;
byte[] expected = { 0, 0x0F };
byte[] expected = [0, 0x0F];
Assert.Multiple(() =>
{
@ -58,7 +58,7 @@ internal class UInt16Tests
public void TryWriteLittleEndian_RReturnsFalse_GivenSmallSpan()
{
const ushort value = 0x0F;
Span<byte> buffer = stackalloc byte[0];
Span<byte> buffer = [];
Assert.That(value.TryWriteLittleEndianBytes(buffer), Is.False);
}
@ -66,7 +66,7 @@ internal class UInt16Tests
public void TryWriteBigEndian_ReturnsFalse_GivenSmallSpan()
{
const ushort value = 0x0F;
Span<byte> buffer = stackalloc byte[0];
Span<byte> buffer = [];
Assert.That(value.TryWriteBigEndianBytes(buffer), Is.False);
}
}

View File

@ -10,7 +10,7 @@ internal class UInt32Tests
public void GetLittleEndianBytes_ReturnsCorrectValue_WithEndianness()
{
const uint value = 0x0F;
byte[] expected = { 0x0F, 0, 0, 0 };
byte[] expected = [0x0F, 0, 0, 0];
byte[] actual = value.GetLittleEndianBytes();
Assert.That(actual, Is.EqualTo(expected).AsCollection);
@ -20,7 +20,7 @@ internal class UInt32Tests
public void GetBigEndianBytes_ReturnsCorrectValue_WithEndianness()
{
const uint value = 0x0F;
byte[] expected = { 0, 0, 0, 0x0F };
byte[] expected = [0, 0, 0, 0x0F];
byte[] actual = value.GetBigEndianBytes();
Assert.That(actual, Is.EqualTo(expected).AsCollection);
@ -30,7 +30,7 @@ internal class UInt32Tests
public void TryWriteLittleEndian_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan()
{
const uint value = 0x0F;
byte[] expected = { 0x0F, 0, 0, 0 };
byte[] expected = [0x0F, 0, 0, 0];
Assert.Multiple(() =>
{
@ -44,7 +44,7 @@ internal class UInt32Tests
public void TryWriteBigEndian_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan()
{
const uint value = 0x0F;
byte[] expected = { 0, 0, 0, 0x0F };
byte[] expected = [0, 0, 0, 0x0F];
Assert.Multiple(() =>
{
@ -58,7 +58,7 @@ internal class UInt32Tests
public void TryWriteLittleEndian_RReturnsFalse_GivenSmallSpan()
{
const uint value = 0x0F;
Span<byte> buffer = stackalloc byte[0];
Span<byte> buffer = [];
Assert.That(value.TryWriteLittleEndianBytes(buffer), Is.False);
}
@ -66,7 +66,7 @@ internal class UInt32Tests
public void TryWriteBigEndian_ReturnsFalse_GivenSmallSpan()
{
const uint value = 0x0F;
Span<byte> buffer = stackalloc byte[0];
Span<byte> buffer = [];
Assert.That(value.TryWriteBigEndianBytes(buffer), Is.False);
}
}

View File

@ -10,7 +10,7 @@ internal class UInt64Tests
public void GetLittleEndianBytes_ReturnsCorrectValue_WithEndianness()
{
const ulong value = 0x0F;
byte[] expected = { 0x0F, 0, 0, 0, 0, 0, 0, 0 };
byte[] expected = [0x0F, 0, 0, 0, 0, 0, 0, 0];
byte[] actual = value.GetLittleEndianBytes();
Assert.That(actual, Is.EqualTo(expected).AsCollection);
@ -20,7 +20,7 @@ internal class UInt64Tests
public void GetBigEndianBytes_ReturnsCorrectValue_WithEndianness()
{
const ulong value = 0x0F;
byte[] expected = { 0, 0, 0, 0, 0, 0, 0, 0x0F };
byte[] expected = [0, 0, 0, 0, 0, 0, 0, 0x0F];
byte[] actual = value.GetBigEndianBytes();
Assert.That(actual, Is.EqualTo(expected).AsCollection);
@ -30,7 +30,7 @@ internal class UInt64Tests
public void TryWriteLittleEndian_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan()
{
const ulong value = 0x0F;
byte[] expected = { 0x0F, 0, 0, 0, 0, 0, 0, 0 };
byte[] expected = [0x0F, 0, 0, 0, 0, 0, 0, 0];
Assert.Multiple(() =>
{
@ -44,7 +44,7 @@ internal class UInt64Tests
public void TryWriteBigEndian_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan()
{
const ulong value = 0x0F;
byte[] expected = { 0, 0, 0, 0, 0, 0, 0, 0x0F };
byte[] expected = [0, 0, 0, 0, 0, 0, 0, 0x0F];
Assert.Multiple(() =>
{
@ -58,7 +58,7 @@ internal class UInt64Tests
public void TryWriteLittleEndian_RReturnsFalse_GivenSmallSpan()
{
const ulong value = 0x0F;
Span<byte> buffer = stackalloc byte[0];
Span<byte> buffer = [];
Assert.That(value.TryWriteLittleEndianBytes(buffer), Is.False);
}
@ -66,7 +66,7 @@ internal class UInt64Tests
public void TryWriteBigEndian_ReturnsFalse_GivenSmallSpan()
{
const ulong value = 0x0F;
Span<byte> buffer = stackalloc byte[0];
Span<byte> buffer = [];
Assert.That(value.TryWriteBigEndianBytes(buffer), Is.False);
}
}

View File

@ -112,7 +112,7 @@ internal class EnumerableTests
[Test]
public void MinMax_ShouldThrowArgumentNullException_GivenNullSelector()
{
IEnumerable<int> source = Enumerable.Empty<int>();
IEnumerable<int> source = [];
Assert.Throws<ArgumentNullException>(() => source.MinMax((Func<int, int>)(null!)));
Assert.Throws<ArgumentNullException>(() => source.MinMax((Func<int, int>)(null!), null));
}
@ -201,13 +201,13 @@ internal class EnumerableTests
{
Assert.Throws<InvalidOperationException>(() =>
{
IEnumerable<Person> source = Enumerable.Empty<Person>();
IEnumerable<Person> source = [];
_ = source.MinMaxBy(p => p.Age);
});
Assert.Throws<InvalidOperationException>(() =>
{
Person[] source = Array.Empty<Person>();
Person[] source = [];
_ = source.MinMaxBy(p => p.Age);
});
}

View File

@ -9,29 +9,32 @@ internal class ReadOnlySpanTests
[Test]
public void AllShouldReturnTrueForEmptySpan()
{
var span = new ReadOnlySpan<int>();
ReadOnlySpan<int> span = [];
Assert.That(span.All(x => x > 0));
}
[Test]
public void AllShouldBeCorrect()
{
var span = new ReadOnlySpan<int>(new[] { 2, 4, 6, 8, 10 });
Assert.That(span.All(x => x % 2 == 0));
Assert.That(span.All(x => x % 2 == 1), Is.False);
Assert.Multiple(() =>
{
ReadOnlySpan<int> span = [2, 4, 6, 8, 10];
Assert.That(span.All(x => x % 2 == 0));
Assert.That(span.All(x => x % 2 == 1), Is.False);
});
}
[Test]
public void AnyShouldReturnFalseForEmptySpan()
{
var span = new ReadOnlySpan<int>();
ReadOnlySpan<int> span = [];
Assert.That(span.Any(x => x > 0), Is.False);
}
[Test]
public void AnyShouldBeCorrect()
{
var span = new ReadOnlySpan<int>(new[] { 2, 4, 6, 8, 10 });
ReadOnlySpan<int> span = [2, 4, 6, 8, 10];
Assert.That(span.Any(x => x % 2 == 0));
Assert.That(span.Any(x => x % 2 == 1), Is.False);
}
@ -41,7 +44,7 @@ internal class ReadOnlySpanTests
{
Assert.Throws<ArgumentNullException>(() =>
{
var span = new ReadOnlySpan<int>();
ReadOnlySpan<int> span = [];
_ = span.All(null!);
});
}
@ -51,7 +54,7 @@ internal class ReadOnlySpanTests
{
Assert.Throws<ArgumentNullException>(() =>
{
var span = new ReadOnlySpan<int>();
ReadOnlySpan<int> span = [];
_ = span.Any(null!);
});
}
@ -59,14 +62,14 @@ internal class ReadOnlySpanTests
[Test]
public void Count_ShouldReturn0_GivenEmptySpan()
{
var span = new ReadOnlySpan<int>();
ReadOnlySpan<int> span = [];
Assert.That(span.Count(i => i % 2 == 0), Is.Zero);
}
[Test]
public void Count_ShouldReturn5_ForEvenNumbers_GivenNumbers1To10()
{
var span = new ReadOnlySpan<int>(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
ReadOnlySpan<int> span = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
Assert.That(span.Count(i => i % 2 == 0), Is.EqualTo(5));
}
@ -75,7 +78,7 @@ internal class ReadOnlySpanTests
{
Assert.Throws<ArgumentNullException>(() =>
{
var span = new ReadOnlySpan<int>();
ReadOnlySpan<int> span = [];
_ = span.Count((Predicate<int>)null!);
});
}

View File

@ -9,31 +9,37 @@ internal class SpanTests
[Test]
public void AllShouldReturnTrueForEmptySpan()
{
var span = new Span<int>();
Span<int> span = [];
Assert.That(span.All(x => x > 0));
}
[Test]
public void AllShouldBeCorrect()
{
var span = new Span<int>(new[] { 2, 4, 6, 8, 10 });
Assert.That(span.All(x => x % 2 == 0));
Assert.That(span.All(x => x % 2 == 1), Is.False);
Assert.Multiple(() =>
{
Span<int> span = [2, 4, 6, 8, 10];
Assert.That(span.All(x => x % 2 == 0));
Assert.That(span.All(x => x % 2 == 1), Is.False);
});
}
[Test]
public void AnyShouldReturnFalseForEmptySpan()
{
var span = new Span<int>();
Span<int> span = [];
Assert.That(span.Any(x => x > 0), Is.False);
}
[Test]
public void AnyShouldBeCorrect()
{
var span = new Span<int>(new[] { 2, 4, 6, 8, 10 });
Assert.That(span.Any(x => x % 2 == 0));
Assert.That(span.Any(x => x % 2 == 1), Is.False);
Assert.Multiple(() =>
{
Span<int> span = [2, 4, 6, 8, 10];
Assert.That(span.Any(x => x % 2 == 0));
Assert.That(span.Any(x => x % 2 == 1), Is.False);
});
}
[Test]
@ -41,7 +47,7 @@ internal class SpanTests
{
Assert.Throws<ArgumentNullException>(() =>
{
var span = new Span<int>();
Span<int> span = [];
_ = span.All(null!);
});
}
@ -51,7 +57,7 @@ internal class SpanTests
{
Assert.Throws<ArgumentNullException>(() =>
{
var span = new Span<int>();
Span<int> span = [];
_ = span.Any(null!);
});
}
@ -59,14 +65,14 @@ internal class SpanTests
[Test]
public void Count_ShouldReturn0_GivenEmptySpan()
{
var span = new Span<int>();
Span<int> span = [];
Assert.That(span.Count(i => i % 2 == 0), Is.Zero);
}
[Test]
public void Count_ShouldReturn5_ForEvenNumbers_GivenNumbers1To10()
{
var span = new Span<int>(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
Span<int> span = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
Assert.That(span.Count(i => i % 2 == 0), Is.EqualTo(5));
}
@ -75,7 +81,7 @@ internal class SpanTests
{
Assert.Throws<ArgumentNullException>(() =>
{
var span = new Span<int>();
Span<int> span = [];
_ = span.Count((Predicate<int>)null!);
});
}

View File

@ -22,8 +22,8 @@ internal class EnumerableTests
[Test]
public void Grep_ShouldYieldNoResults_GivenEmptySource()
{
string[] source = Array.Empty<string>();
string[] expectedResult = Array.Empty<string>();
string[] source = [];
string[] expectedResult = [];
const string pattern = /*lang=regex*/@"[0-9]+";
string[] actualResult = source.Grep(pattern).ToArray();
@ -59,7 +59,7 @@ internal class EnumerableTests
[Test]
public void Grep_ShouldThrowArgumentNullException_GivenNullPattern()
{
IEnumerable<string> source = Enumerable.Empty<string>();
IEnumerable<string> source = [];
Assert.Multiple(() =>
{
Assert.Throws<ArgumentNullException>(() => source.Grep(null!).ToArray());

View File

@ -18,7 +18,7 @@ public static class Extensions
[Pure]
public static T[] AsArrayValue<T>(this T value)
{
return new[] {value};
return [value];
}
/// <summary>

View File

@ -8,7 +8,7 @@ namespace X10D.Drawing;
/// </summary>
public class Polygon : IEquatable<Polygon>
{
private readonly List<Point> _vertices = new();
private readonly List<Point> _vertices = [];
/// <summary>
/// Initializes a new instance of the <see cref="Polygon" /> class.
@ -27,7 +27,7 @@ public class Polygon : IEquatable<Polygon>
throw new ArgumentNullException(nameof(polygon));
}
_vertices = new List<Point>();
_vertices = [];
for (var index = 0; index < polygon._vertices.Count; index++)
{
Point vertex = polygon._vertices[index];
@ -46,7 +46,7 @@ public class Polygon : IEquatable<Polygon>
throw new ArgumentNullException(nameof(vertices));
}
_vertices = new List<Point>(vertices);
_vertices = [..vertices];
}
/// <summary>

View File

@ -10,7 +10,7 @@ namespace X10D.Drawing;
/// </summary>
public class PolygonF
{
private readonly List<PointF> _vertices = new();
private readonly List<PointF> _vertices = [];
/// <summary>
/// Initializes a new instance of the <see cref="PolygonF" /> class.
@ -29,7 +29,7 @@ public class PolygonF
{
throw new ArgumentNullException(nameof(polygon));
}
_vertices = new List<PointF>();
_vertices = [];
for (var index = 0; index < polygon._vertices.Count; index++)
{
PointF vertex = polygon._vertices[index];
@ -49,7 +49,7 @@ public class PolygonF
throw new ArgumentNullException(nameof(vertices));
}
_vertices = new List<PointF>();
_vertices = [];
foreach (Vector2 vertex in vertices)
{
_vertices.Add(vertex.ToPointF());
@ -68,7 +68,7 @@ public class PolygonF
throw new ArgumentNullException(nameof(vertices));
}
_vertices = new List<PointF>(vertices);
_vertices = [..vertices];
}
/// <summary>

View File

@ -9,7 +9,7 @@ namespace X10D.Drawing;
/// </summary>
public class Polyhedron : IEquatable<Polyhedron>
{
private readonly List<Vector3> _vertices = new();
private readonly List<Vector3> _vertices = [];
/// <summary>
/// Initializes a new instance of the <see cref="Polyhedron" /> class.
@ -39,7 +39,7 @@ public class Polyhedron : IEquatable<Polyhedron>
throw new ArgumentNullException(nameof(vertices));
}
_vertices = new List<Vector3>(vertices);
_vertices = [..vertices];
}
/// <summary>