mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-09 22:55:42 +00:00
Move Span.Any/All to Linq namespace (#7)
This commit is contained in:
parent
0fb01726db
commit
d5a74c12a8
58
X10D.Tests/src/Linq/ReadOnlySpanTests.cs
Normal file
58
X10D.Tests/src/Linq/ReadOnlySpanTests.cs
Normal file
@ -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<int>();
|
||||
Assert.IsTrue(span.All(x => x > 0));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AllShouldBeCorrect()
|
||||
{
|
||||
var span = new ReadOnlySpan<int>(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<int>();
|
||||
Assert.IsFalse(span.Any(x => x > 0));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AnyShouldBeCorrect()
|
||||
{
|
||||
var span = new ReadOnlySpan<int>(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<ArgumentNullException>(() =>
|
||||
{
|
||||
var span = new ReadOnlySpan<int>();
|
||||
return span.All(null!);
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AnyNullPredicateShouldThrow()
|
||||
{
|
||||
Assert.ThrowsException<ArgumentNullException>(() =>
|
||||
{
|
||||
var span = new ReadOnlySpan<int>();
|
||||
return span.Any(null!);
|
||||
});
|
||||
}
|
||||
}
|
58
X10D.Tests/src/Linq/SpanTests.cs
Normal file
58
X10D.Tests/src/Linq/SpanTests.cs
Normal file
@ -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<int>();
|
||||
Assert.IsTrue(span.All(x => x > 0));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AllShouldBeCorrect()
|
||||
{
|
||||
var span = new Span<int>(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<int>();
|
||||
Assert.IsFalse(span.Any(x => x > 0));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AnyShouldBeCorrect()
|
||||
{
|
||||
var span = new Span<int>(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<ArgumentNullException>(() =>
|
||||
{
|
||||
var span = new Span<int>();
|
||||
return span.All(null!);
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AnyNullPredicateShouldThrow()
|
||||
{
|
||||
Assert.ThrowsException<ArgumentNullException>(() =>
|
||||
{
|
||||
var span = new Span<int>();
|
||||
return span.Any(null!);
|
||||
});
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
namespace X10D;
|
||||
namespace X10D.Linq;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for <see cref="ReadOnlySpan{T}" />.
|
@ -1,4 +1,4 @@
|
||||
namespace X10D;
|
||||
namespace X10D.Linq;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for <see cref="Span{T}" />.
|
Loading…
Reference in New Issue
Block a user