package xyz.jadonfowler.o.test;

import xyz.jadonfowler.o.O;

public class TestSuite {

    private static O o;

    public static void main(String[] args) throws Exception {
        o = new O();
        O.instance = o;
        //checkParse("", "");
        checkParse("\"Hello World\"o", "Hello World");
        checkParse("12+o", "3");
        checkParse("[123]+o", "6");
        checkParse("[12] (4]*o", "8");
        checkParse("[3,]2^+o", "14");
    }

    public static void checkParse(String code, String expected) throws Exception {
        String result = "";
        for (char c : code.toCharArray())
            result += o.parse(c);
        if (!(result.equals(expected)))
            throw new Exception("'" + result + "' should be '" + expected + "' for '" + code + "'");
    }

}

@@ -37,27 +37,96 @@
 ort 
-xyz.jadonfowler.o.O
+static org.junit.Assert.assertEquals;%0A%0Aimport xyz.jadonfowler.o.O;%0Aimport org.junit.Test
 ;%0A%0Ap
@@ -162,23 +162,16 @@
 private 
-static 
 O o;%0A%0A  
@@ -176,63 +176,44 @@
     
-public static void main(String%5B%5D args) throws Exception
+@Test%0A    public void testOParsing()
  %7B%0A 
@@ -270,24 +270,92 @@
   //
-checkParse(%22%22
+assertEquals(%22%22, parse(%22%22), %22%22);%0A        assertEquals(%2212+o -%3E 3%22, parse(%2212+o%22)
 , %22
+3
 %22);%0A
@@ -358,30 +358,73 @@
 %22);%0A        
-checkP
+assertEquals(%22%5C%22Hello World%5C%22o -%3E Hello World%22, p
 arse(%22%5C%22Hell
@@ -434,16 +434,17 @@
 orld%5C%22o%22
+)
 , %22Hello
@@ -465,47 +465,38 @@
     
-checkParse
+assertEquals
 (%22
+%5B
 12
-+o%22, %223%22);%0A        checkP
+3%5D+o -%3E 6%22, p
 arse
@@ -505,16 +505,17 @@
 %5B123%5D+o%22
+)
 , %226%22);%0A
@@ -518,30 +518,57 @@
 %22);%0A        
-checkP
+assertEquals(%22%5B12%5D (4%5D*o -%3E 8%22, p
 arse(%22%5B12%5D (
@@ -572,16 +572,17 @@
 %5D (4%5D*o%22
+)
 , %228%22);%0A
@@ -589,22 +589,48 @@
         
-checkP
+assertEquals(%22%5B3,%5D2%5E+o -%3E 14%22, p
 arse(%22%5B3
@@ -636,16 +636,17 @@
 3,%5D2%5E+o%22
+)
 , %2214%22);
@@ -668,77 +668,30 @@
 lic 
-static void checkParse(
 String 
-code, 
+parse(
 String 
-expected) throws Exception
+s)
  %7B%0A 
@@ -739,20 +739,17 @@
 har c : 
-code
+s
 .toCharA
@@ -755,16 +755,18 @@
 Array())
+ %7B
 %0A       
@@ -804,139 +804,31 @@
     
-if (!(result.equals(expected)))%0A            throw new Exception(%22'%22 + result + %22' should be '%22 + expected + %22' for '%22 + code + %22'%22)
+%7D%0A        return result
 ;%0A  

switch to JUnit