Added unit test to cover issue #8
This commit is contained in:
parent
9024752b53
commit
faf6c99c19
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using FastRng;
|
||||
using FastRng.Distributions;
|
||||
using NUnit.Framework;
|
||||
@ -222,6 +223,32 @@ public class MultiThreadedRngTests
|
||||
Assert.That(lorentzContains0, Is.False, "Lorentz distribution contained 0");
|
||||
Assert.That(lorentzContains1, Is.True, "Lorentz distribution does not contained 1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category(TestCategories.LONG_RUNNING)]
|
||||
public void TestMultiThreadedConsumer()
|
||||
{
|
||||
var job1 = Task.Factory.StartNew(Run, TaskCreationOptions.LongRunning);
|
||||
var job2 = Task.Factory.StartNew(Run, TaskCreationOptions.LongRunning);
|
||||
var job3 = Task.Factory.StartNew(Run, TaskCreationOptions.LongRunning);
|
||||
|
||||
Assert.DoesNotThrowAsync(async () => await job1);
|
||||
Assert.DoesNotThrowAsync(async () => await job2);
|
||||
Assert.DoesNotThrowAsync(async () => await job3);
|
||||
return;
|
||||
|
||||
float Run()
|
||||
{
|
||||
var sum = 0f;
|
||||
var distLorentz = new CauchyLorentzX1<float>(this.rng);
|
||||
for (int i = 0; i < 100_000_000; i++)
|
||||
{
|
||||
sum += distLorentz.NextNumber();
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category(TestCategories.COVER)]
|
||||
|
Loading…
Reference in New Issue
Block a user