Skip to content

Commit 7ced497

Browse files
author
Dmitry Pentin
committed
Fixed tests
1 parent f3b8e5c commit 7ced497

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

tests/ImageSharp.Tests/Common/NumericsTests.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ public NumericsTests(ITestOutputHelper output)
1616
this.Output = output;
1717
}
1818

19+
public static TheoryData<int> IsOutOfRangeTestData = new() { int.MinValue, -1, 0, 1, 6, 7, 8, 91, 92, 93, int.MaxValue };
20+
1921
private static int Log2_ReferenceImplementation(uint value)
2022
{
2123
int n = 0;
@@ -101,21 +103,16 @@ public void DivideCeil_RandomValues(int seed, int count)
101103
private static bool IsOutOfRange_ReferenceImplementation(int value, int min, int max) => value < min || value > max;
102104

103105
[Theory]
104-
[InlineData(1, 100)]
105-
public void IsOutOfRange(int seed, int count)
106+
[MemberData(nameof(IsOutOfRangeTestData))]
107+
public void IsOutOfRange(int value)
106108
{
107-
var rng = new Random(seed);
108-
for (int i = 0; i < count; i++)
109-
{
110-
int value = rng.Next();
111-
int min = rng.Next();
112-
int max = rng.Next(min, int.MaxValue);
109+
const int min = 7;
110+
const int max = 92;
113111

114-
bool expected = IsOutOfRange_ReferenceImplementation(value, min, max);
115-
bool actual = Numerics.IsOutOfRange(value, min, max);
112+
bool expected = IsOutOfRange_ReferenceImplementation(value, min, max);
113+
bool actual = Numerics.IsOutOfRange(value, min, max);
116114

117-
Assert.True(expected == actual, $"IsOutOfRange({value}, {min}, {max})");
118-
}
115+
Assert.True(expected == actual, $"IsOutOfRange({value}, {min}, {max})");
119116
}
120117
}
121118
}

0 commit comments

Comments
 (0)