-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathLinearSieveOfEratosthenesTests.cs
46 lines (41 loc) · 1.36 KB
/
LinearSieveOfEratosthenesTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using Algorithms.Numeric;
using System.Linq;
using Xunit;
using Xunit.Abstractions;
using System.Diagnostics;
namespace UnitTest.AlgorithmsTests
{
public class LinearSieveOfEratosthenesTests
{
private readonly ITestOutputHelper _testOutputHelper;
public LinearSieveOfEratosthenesTests(ITestOutputHelper testOutputHelper)
{
_testOutputHelper = testOutputHelper;
}
private const int MaxNumber = 100;
[Fact]
public void DoTests()
{
var results = LinearSieveOfEratosthenes.GeneratePrimesUpTo(MaxNumber);
Assert.NotNull(results);
Assert.True(results.Any());
Assert.Equal(results.Count(), 25);
Assert.DoesNotContain(1, results);
Assert.Contains(2, results);
Assert.Contains(7, results);
Assert.Contains(23, results);
Assert.Contains(41, results);
Assert.Contains(97, results);
}
[Fact]
public void TestsForEmpty()
{
var results = LinearSieveOfEratosthenes.GeneratePrimesUpTo(0);
Assert.NotNull(results);
Assert.False(results.Any());
var results2 = LinearSieveOfEratosthenes.GeneratePrimesUpTo(-100);
Assert.NotNull(results2);
Assert.False(results2.Any());
}
}
}