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>
This commit is contained in:
Adrian Conlon
2019-08-13 18:51:34 +01:00
parent 3c7ca33efe
commit 63ef445a78
13 changed files with 86 additions and 39 deletions
@@ -39,6 +39,7 @@
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RegisterState.cs" />
<Compile Include="TestRunner.cs" />
<Compile Include="TestSuite.cs" />
</ItemGroup>
+1 -1
View File
@@ -8,7 +8,7 @@ namespace Fuse
{
public static void Main(string[] args)
{
var suite = new TestSuite("fuse-tests\\tests");
var suite = new TestSuite<RegisterState>("fuse-tests\\tests");
suite.Read();
suite.Parse();
suite.Run();
+17
View File
@@ -0,0 +1,17 @@
// <copyright file="RegisterState.cs" company="Adrian Conlon">
// Copyright (c) Adrian Conlon. All rights reserved.
// </copyright>
namespace Fuse
{
using System;
using System.Globalization;
public class RegisterState : AbstractRegisterState, IRegisterState
{
protected override void ParseInternalState(string[] tokens)
{
this.Halted = Convert.ToInt32(tokens[0], CultureInfo.InvariantCulture) == 1;
this.TStates = Convert.ToInt32(tokens[1], CultureInfo.InvariantCulture);
}
}
}
+5 -4
View File
@@ -14,13 +14,14 @@ namespace Fuse
PC,
}
public class TestRunner : EightBit.GameBoy.Bus
public class TestRunner<T> : EightBit.GameBoy.Bus
where T : Fuse.IRegisterState, new()
{
private readonly Test test;
private readonly Result result;
private readonly Test<T> test;
private readonly Result<T> result;
private readonly EightBit.Ram ram = new EightBit.Ram(0x10000);
public TestRunner(Test test, Result result)
public TestRunner(Test<T> test, Result<T> result)
{
this.test = test;
this.result = result;
+7 -6
View File
@@ -3,15 +3,16 @@
// </copyright>
namespace Fuse
{
public class TestSuite
public class TestSuite<T>
where T : Fuse.IRegisterState, new()
{
private readonly Tests tests;
private readonly Results results;
private readonly Tests<T> tests;
private readonly Results<T> results;
public TestSuite(string path)
{
this.tests = new Tests(path + ".in");
this.results = new Results(path + ".expected");
this.tests = new Tests<T>(path + ".in");
this.results = new Results<T>(path + ".expected");
}
public void Read()
@@ -37,7 +38,7 @@ namespace Fuse
var input = test.Value;
var result = this.results.Container[key];
var runner = new TestRunner(input, result);
var runner = new TestRunner<T>(input, result);
runner.Run();
if (runner.Failed)