From 788b8cc4dd404a826ce881c020ee6ca0388a5975 Mon Sep 17 00:00:00 2001 From: Ian C Date: Thu, 1 Mar 2012 00:02:07 +0000 Subject: Initial working version of test suite. Fixed INC8 and DEC8 with results. --- .../Program.cs | 71 +++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) (limited to 'native/Noddybox.Emulation.EightBit.Z80.Test/Program.cs') 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 /// class Program { + static Queue GetBlock(StreamReader str) + { + Queue q = new Queue(); + 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 t = GetBlock(test); + Queue 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; + } + } } } } -- cgit v1.3