summaryrefslogtreecommitdiff
path: root/native/Noddybox.Emulation.EightBit.Z80.Test/Program.cs
diff options
context:
space:
mode:
Diffstat (limited to 'native/Noddybox.Emulation.EightBit.Z80.Test/Program.cs')
-rw-r--r--native/Noddybox.Emulation.EightBit.Z80.Test/Program.cs71
1 files changed, 70 insertions, 1 deletions
diff --git a/native/Noddybox.Emulation.EightBit.Z80.Test/Program.cs b/native/Noddybox.Emulation.EightBit.Z80.Test/Program.cs
index 0f2a19d..43dab10 100644
--- a/native/Noddybox.Emulation.EightBit.Z80.Test/Program.cs
+++ b/native/Noddybox.Emulation.EightBit.Z80.Test/Program.cs
@@ -19,6 +19,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using System.IO;
namespace Noddybox.Emulation.EightBit.Z80.Test
{
@@ -28,9 +29,77 @@ namespace Noddybox.Emulation.EightBit.Z80.Test
/// </summary>
class Program
{
+ static Queue<string> GetBlock(StreamReader str)
+ {
+ Queue<string> q = new Queue<string>();
+ bool process = false;
+
+ while(!str.EndOfStream)
+ {
+ string s = str.ReadLine();
+
+ if (process)
+ {
+ if (s.Trim().Length == 0)
+ {
+ return q;
+ }
+
+ q.Enqueue(s);
+ }
+ else
+ {
+ if (s.Trim().Length > 0)
+ {
+ process = true;
+ q.Enqueue(s);
+ }
+ }
+ }
+
+ return q;
+ }
+
static void Main(string[] args)
{
- new TestMachine("Test", null, null);
+ try
+ {
+ StreamReader test = new StreamReader("tests.in");
+ StreamReader expected = new StreamReader("tests.expected");
+
+ while(!test.EndOfStream)
+ {
+ Queue<string> t = GetBlock(test);
+ Queue<string> e = GetBlock(expected);
+
+ if (t.Count > 0)
+ {
+ if (t.Peek() != e.Peek())
+ {
+ throw new Exception(String.Format("Test name {0}, expected name {1}", t.Peek(), e.Peek()));
+ }
+
+ TestMachine m = new TestMachine();
+ e.Dequeue();
+
+ if (!m.Run(t.Dequeue(), t, e))
+ {
+ Console.ReadKey(true);
+ }
+ }
+ }
+
+ test.Close();
+ expected.Close();
+ }
+ catch (Exception e)
+ {
+ while (e != null)
+ {
+ Console.WriteLine("**** {0}: {1}", e.GetType(), e.Message);
+ e = e.InnerException;
+ }
+ }
}
}
}