diff --git a/X10D.Tests/src/Linq/ReadOnlySpanTests.cs b/X10D.Tests/src/Linq/ReadOnlySpanTests.cs new file mode 100644 index 0000000..e33f5cd --- /dev/null +++ b/X10D.Tests/src/Linq/ReadOnlySpanTests.cs @@ -0,0 +1,58 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using X10D.Linq; + +namespace X10D.Tests.Linq; + +[TestClass] +public class ReadOnlySpanTests +{ + [TestMethod] + public void AllShouldReturnTrueForEmptySpan() + { + var span = new ReadOnlySpan(); + Assert.IsTrue(span.All(x => x > 0)); + } + + [TestMethod] + public void AllShouldBeCorrect() + { + var span = new ReadOnlySpan(new[] {2, 4, 6, 8, 10}); + Assert.IsTrue(span.All(x => x % 2 == 0)); + Assert.IsFalse(span.All(x => x % 2 == 1)); + } + + [TestMethod] + public void AnyShouldReturnFalseForEmptySpan() + { + var span = new ReadOnlySpan(); + Assert.IsFalse(span.Any(x => x > 0)); + } + + [TestMethod] + public void AnyShouldBeCorrect() + { + var span = new ReadOnlySpan(new[] {2, 4, 6, 8, 10}); + Assert.IsTrue(span.Any(x => x % 2 == 0)); + Assert.IsFalse(span.Any(x => x % 2 == 1)); + } + + [TestMethod] + public void AllNullPredicateShouldThrow() + { + Assert.ThrowsException(() => + { + var span = new ReadOnlySpan(); + return span.All(null!); + }); + } + + [TestMethod] + public void AnyNullPredicateShouldThrow() + { + Assert.ThrowsException(() => + { + var span = new ReadOnlySpan(); + return span.Any(null!); + }); + } +} diff --git a/X10D.Tests/src/Linq/SpanTests.cs b/X10D.Tests/src/Linq/SpanTests.cs new file mode 100644 index 0000000..98c5fe3 --- /dev/null +++ b/X10D.Tests/src/Linq/SpanTests.cs @@ -0,0 +1,58 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using X10D.Linq; + +namespace X10D.Tests.Linq; + +[TestClass] +public class SpanTests +{ + [TestMethod] + public void AllShouldReturnTrueForEmptySpan() + { + var span = new Span(); + Assert.IsTrue(span.All(x => x > 0)); + } + + [TestMethod] + public void AllShouldBeCorrect() + { + var span = new Span(new[] {2, 4, 6, 8, 10}); + Assert.IsTrue(span.All(x => x % 2 == 0)); + Assert.IsFalse(span.All(x => x % 2 == 1)); + } + + [TestMethod] + public void AnyShouldReturnFalseForEmptySpan() + { + var span = new Span(); + Assert.IsFalse(span.Any(x => x > 0)); + } + + [TestMethod] + public void AnyShouldBeCorrect() + { + var span = new Span(new[] {2, 4, 6, 8, 10}); + Assert.IsTrue(span.Any(x => x % 2 == 0)); + Assert.IsFalse(span.Any(x => x % 2 == 1)); + } + + [TestMethod] + public void AllNullPredicateShouldThrow() + { + Assert.ThrowsException(() => + { + var span = new Span(); + return span.All(null!); + }); + } + + [TestMethod] + public void AnyNullPredicateShouldThrow() + { + Assert.ThrowsException(() => + { + var span = new Span(); + return span.Any(null!); + }); + } +} diff --git a/X10D/src/SpanExtensions/ReadOnlySpanExtensions.cs b/X10D/src/Linq/ReadOnlySpanExtensions.cs similarity index 99% rename from X10D/src/SpanExtensions/ReadOnlySpanExtensions.cs rename to X10D/src/Linq/ReadOnlySpanExtensions.cs index 66dc7e9..3d1981c 100644 --- a/X10D/src/SpanExtensions/ReadOnlySpanExtensions.cs +++ b/X10D/src/Linq/ReadOnlySpanExtensions.cs @@ -1,4 +1,4 @@ -namespace X10D; +namespace X10D.Linq; /// /// Extension methods for . diff --git a/X10D/src/SpanExtensions/SpanExtensions.cs b/X10D/src/Linq/SpanExtensions.cs similarity index 99% rename from X10D/src/SpanExtensions/SpanExtensions.cs rename to X10D/src/Linq/SpanExtensions.cs index f1e9a9d..641c54b 100644 --- a/X10D/src/SpanExtensions/SpanExtensions.cs +++ b/X10D/src/Linq/SpanExtensions.cs @@ -1,4 +1,4 @@ -namespace X10D; +namespace X10D.Linq; /// /// Extension methods for .