EightBitNet/LR35902/LR35902.FuseTest/TestSuite.cs
Adrian Conlon 63ef445a78 Make the Fuse test classes more generic, so I can use them again for the Z80 fuse runner.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
2019-08-13 18:51:34 +01:00

60 lines
1.6 KiB
C#

// <copyright file="TestSuite.cs" company="Adrian Conlon">
// Copyright (c) Adrian Conlon. All rights reserved.
// </copyright>
namespace Fuse
{
public class TestSuite<T>
where T : Fuse.IRegisterState, new()
{
private readonly Tests<T> tests;
private readonly Results<T> results;
public TestSuite(string path)
{
this.tests = new Tests<T>(path + ".in");
this.results = new Results<T>(path + ".expected");
}
public void Read()
{
this.tests.Read();
this.results.Read();
}
public void Parse()
{
this.tests.Parse();
this.results.Parse();
}
public void Run()
{
var failedCount = 0;
var unimplementedCount = 0;
foreach (var test in this.tests.Container)
{
var key = test.Key;
System.Console.Out.WriteLine($"** Checking: {key}");
var input = test.Value;
var result = this.results.Container[key];
var runner = new TestRunner<T>(input, result);
runner.Run();
if (runner.Failed)
{
++failedCount;
}
if (runner.Unimplemented)
{
++unimplementedCount;
}
}
System.Console.Out.WriteLine($"+++ Failed test count: {failedCount}");
System.Console.Out.WriteLine($"+++ Unimplemented test count: {unimplementedCount}");
}
}
}