32 lines
1.1 KiB
C#
32 lines
1.1 KiB
C#
using NUnit.Framework;
|
|
using ProjectQuint.Probes;
|
|
|
|
namespace ProjectQuint.Tests
|
|
{
|
|
public sealed class CoreBenchmarkTests
|
|
{
|
|
[Test]
|
|
public void Benchmark_CheckpointsAreIncompleteUntilEverySampleFinishes()
|
|
{
|
|
var checkpoints = 0;
|
|
var report = CoreBenchmark.Run(100, 42, 60, 3, checkpoint =>
|
|
{
|
|
++checkpoints;
|
|
Assert.That(checkpoint.Complete, Is.False);
|
|
Assert.That(checkpoint.Samples.Length, Is.EqualTo(checkpoints));
|
|
Assert.That(checkpoint.Samples[0].Judgement.Finished, Is.True);
|
|
});
|
|
Assert.That(report.Complete, Is.True);
|
|
Assert.That(checkpoints, Is.EqualTo(3));
|
|
Assert.That(report.Samples.Length, Is.EqualTo(3));
|
|
Assert.That(report.WarmupIterations, Is.EqualTo(3));
|
|
}
|
|
|
|
[TestCase(0)]
|
|
[TestCase(101)]
|
|
public void Benchmark_RejectsInvalidIterationCount(int iterations) =>
|
|
Assert.Throws<System.ArgumentOutOfRangeException>(() =>
|
|
CoreBenchmark.Run(100, 42, 60, iterations, _ => { }));
|
|
}
|
|
}
|