Skip to content

Commit

Permalink
refactor!: replace Product and RangeTo on int types with generic math
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverbooth committed Nov 14, 2024
1 parent 0d6153d commit b1c644d
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 721 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## 4.0.1 - [Unreleased]

### Changed

- X10D: Removed `byte.Product`, `short.Product`, `ushort.Product`, `int.Product`, `uint.Product`, `long.Product`,
and `ulong.Product`, in favour of `INumber<T>.Product`.
- X10D: Removed `byte.RangeTo`, `short.RangeTo`, `ushort.RangeTo`, `int.RangeTo`, `uint.RangeTo`, `long.RangeTo`,
and `ulong.RangeTo`, in favour of `INumber<T>.RangeTo`.

### Removed

- X10D: Removed `Span<T>.Split` for .NET 9.0 target due to conflicts with
Expand Down
47 changes: 1 addition & 46 deletions X10D.Tests/src/Linq/ByteTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void Product_ShouldThrowArgumentNullException_GivenNullSource()
}

[Test]
public void RangeTo_Byte_ShouldYieldCorrectValues()
public void RangeTo_ShouldYieldCorrectValues()
{
const byte start = 1;
const byte end = 10;
Expand All @@ -56,49 +56,4 @@ public void RangeTo_Byte_ShouldYieldCorrectValues()

Assert.That(current, Is.EqualTo(end));
}

[Test]
public void RangeTo_Int16_ShouldYieldCorrectValues()
{
const byte start = 1;
const short end = 10;

short current = 1;
foreach (short value in start.RangeTo(end))
{
Assert.That(value, Is.EqualTo(current++));
}

Assert.That(current, Is.EqualTo(end));
}

[Test]
public void RangeTo_Int32_ShouldYieldCorrectValues()
{
const byte start = 1;
const int end = 10;

int current = 1;
foreach (int value in start.RangeTo(end))
{
Assert.That(value, Is.EqualTo(current++));
}

Assert.That(current, Is.EqualTo(end));
}

[Test]
public void RangeTo_Int64_ShouldYieldCorrectValues()
{
const byte start = 1;
const long end = 10;

long current = 1;
foreach (long value in start.RangeTo(end))
{
Assert.That(value, Is.EqualTo(current++));
}

Assert.That(current, Is.EqualTo(end));
}
}
34 changes: 1 addition & 33 deletions X10D.Tests/src/Linq/Int16Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void Product_ShouldThrowArgumentNullException_GivenNullSource()
}

[Test]
public void RangeTo_Int16_ShouldYieldCorrectValues()
public void RangeTo_ShouldYieldCorrectValues()
{
const short start = 1;
const short end = 10;
Expand All @@ -60,36 +60,4 @@ public void RangeTo_Int16_ShouldYieldCorrectValues()

Assert.That(current, Is.EqualTo(end));
}

[Test]
public void RangeTo_Int32_ShouldYieldCorrectValues()
{
const short start = 1;
const int end = 10;

var current = 1;

foreach (int value in start.RangeTo(end))
{
Assert.That(value, Is.EqualTo(current++));
}

Assert.That(current, Is.EqualTo(end));
}

[Test]
public void RangeTo_Int64_ShouldYieldCorrectValues()
{
const short start = 1;
const long end = 10;

long current = 1;

foreach (long value in start.RangeTo(end))
{
Assert.That(value, Is.EqualTo(current++));
}

Assert.That(current, Is.EqualTo(end));
}
}
16 changes: 1 addition & 15 deletions X10D.Tests/src/Linq/Int32Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void Product_ShouldThrowArgumentNullException_GivenNullSource()
}

[Test]
public void RangeTo_Int32_ShouldYieldCorrectValues()
public void RangeTo_ShouldYieldCorrectValues()
{
const int start = 1;
const int end = 10;
Expand All @@ -64,18 +64,4 @@ public void RangeTo_Int32_ShouldYieldCorrectValues()
Assert.That(current, Is.EqualTo(end));
}

[Test]
public void RangeTo_Int64_ShouldYieldCorrectValues()
{
const int start = 1;
const long end = 10;

long current = 1;
foreach (long value in start.RangeTo(end))
{
Assert.That(value, Is.EqualTo(current++));
}

Assert.That(current, Is.EqualTo(end));
}
}
2 changes: 1 addition & 1 deletion X10D.Tests/src/Linq/Int64Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void Product_ShouldThrowArgumentNullException_GivenNullSource()
}

[Test]
public void RangeTo_Int64_ShouldYieldCorrectValues()
public void RangeTo_ShouldYieldCorrectValues()
{
const long start = 1;
const long end = 10;
Expand Down
161 changes: 0 additions & 161 deletions X10D/src/Linq/ByteExtensions.cs

This file was deleted.

42 changes: 0 additions & 42 deletions X10D/src/Linq/DecimalExtensions.cs

This file was deleted.

Loading

0 comments on commit b1c644d

Please sign in to comment.