diff options
Diffstat (limited to 'src/test/java/bjc/everge')
| -rw-r--r-- | src/test/java/bjc/everge/EvergeTest.java | 9 | ||||
| -rw-r--r-- | src/test/java/bjc/everge/ReplPairTest.java | 11 | ||||
| -rw-r--r-- | src/test/java/bjc/everge/StringUtilsTest.java | 10 | ||||
| -rw-r--r-- | src/test/java/bjc/everge/TestUtils.java | 50 |
4 files changed, 47 insertions, 33 deletions
diff --git a/src/test/java/bjc/everge/EvergeTest.java b/src/test/java/bjc/everge/EvergeTest.java index cfc9147..0ef9939 100644 --- a/src/test/java/bjc/everge/EvergeTest.java +++ b/src/test/java/bjc/everge/EvergeTest.java @@ -51,10 +51,10 @@ public class EvergeTest { evg.setOutput(normOut); evg.setError(normErr); - //evg.processArgs("--verbosity", "3"); + // evg.processArgs("--verbosity", "3"); List<String> errs = new ArrayList<>(); - boolean stat = evg.processArgs(errs, "--input-status", "line", "--file", "data/test/evg-test1.rp", - "data/test/evg-test1.inp"); + boolean stat = evg.processArgs(errs, "--input-status", "line", "--file", + "data/test/evg-test1.rp", "data/test/evg-test1.inp"); if (!stat) { System.err.println("[ERROR] Did not succesfully process args"); for (String err : errs) { @@ -62,7 +62,8 @@ public class EvergeTest { } System.err.println("[ERROR] Normal Output:\n--------------------"); System.err.println(baos.toString().trim()); - System.err.println("--------------------\n[ERROR] Error Output:\n------------------"); + System.err.println( + "--------------------\n[ERROR] Error Output:\n------------------"); System.err.println(errBaos.toString().trim()); System.err.println("--------------------"); diff --git a/src/test/java/bjc/everge/ReplPairTest.java b/src/test/java/bjc/everge/ReplPairTest.java index 8f0a3e8..c2a020c 100644 --- a/src/test/java/bjc/everge/ReplPairTest.java +++ b/src/test/java/bjc/everge/ReplPairTest.java @@ -23,7 +23,8 @@ public class ReplPairTest { List<ReplPair> lrp = null; String fName = "data/test/test1.rp"; - try (FileInputStream fis = new FileInputStream(fName); Scanner scn = new Scanner(fis)) { + try (FileInputStream fis = new FileInputStream(fName); + Scanner scn = new Scanner(fis)) { lrp = ReplPair.readList(scn); assertTrue(lrp.size() == 0); @@ -39,7 +40,8 @@ public class ReplPairTest { @Test public void testMultiReplace() { - assertMultiReplace("data/test/test3.rp", "A B C", "a b c", "A A B", "a a b", "AAB", "aab"); + assertMultiReplace("data/test/test3.rp", "A B C", "a b c", "A A B", "a a b", + "AAB", "aab"); } @Test @@ -59,13 +61,12 @@ public class ReplPairTest { @Test public void testErrorException() { - String msg = - "[ERROR] An error occured parsing replacement pairs:" + String msg = "[ERROR] An error occured parsing replacement pairs:" + "\n\t[ERROR] line 2, pair 1: Ran out of input looking for" + " replacement body for raw name 'a'" + "\n\t\tContext: No associated line"; - assertThrownMessage(msg, "data/test/test7.rp"); + assertThrownMessage(msg, "data/test/test7.rp"); } @Test diff --git a/src/test/java/bjc/everge/StringUtilsTest.java b/src/test/java/bjc/everge/StringUtilsTest.java index a1469ae..91af56e 100644 --- a/src/test/java/bjc/everge/StringUtilsTest.java +++ b/src/test/java/bjc/everge/StringUtilsTest.java @@ -14,16 +14,16 @@ import static org.junit.Assert.*; public class StringUtilsTest { @Test public void testNullSplit() { - assertSplitsTo("a", null, " ", "a"); - assertSplitsTo("a b", null, " ", "a", "b"); + assertSplitsTo("a", null, " ", "a"); + assertSplitsTo("a b", null, " ", "a", "b"); assertSplitsTo("a b cd", null, " ", "a", "b", "cd"); } @Test public void testNoEscapeSplit() { - assertSplitsTo("a", "/", " ", "a"); - assertSplitsTo("a b", "/", " ", "a", "b"); - assertSplitsTo("a b/c", "/", " ", "a", "b/c"); + assertSplitsTo("a", "/", " ", "a"); + assertSplitsTo("a b", "/", " ", "a", "b"); + assertSplitsTo("a b/c", "/", " ", "a", "b/c"); } @Test diff --git a/src/test/java/bjc/everge/TestUtils.java b/src/test/java/bjc/everge/TestUtils.java index 6c4b73b..49e962e 100644 --- a/src/test/java/bjc/everge/TestUtils.java +++ b/src/test/java/bjc/everge/TestUtils.java @@ -21,9 +21,9 @@ public class TestUtils { * Assert that a ReplParseException is thrown with a given message. * * @param msg - * The message. + * The message. * @param fle - * The file to load input from. + * The file to load input from. */ public static void assertThrownMessage(String msg, String fle) { assertThrownMessage(false, msg, fle); @@ -33,19 +33,21 @@ public class TestUtils { * Assert that a ReplParseException is thrown with a given message. * * @param logMsg - * Log the exception message. + * Log the exception message. * @param msg - * The message. + * The message. * @param fle - * The file to load input from. + * The file to load input from. */ public static void assertThrownMessage(boolean logMsg, String msg, String fle) { - try (FileInputStream fis = new FileInputStream(fle); Scanner scn = new Scanner(fis)) { + try (FileInputStream fis = new FileInputStream(fle); + Scanner scn = new Scanner(fis)) { ReplPair.readList(new ArrayList<>(), scn); assertTrue(false); } catch (BadReplParse rpex) { - if (logMsg) System.err.println(rpex.toPrintString()); + if (logMsg) + System.err.println(rpex.toPrintString()); assertEquals(msg, rpex.toPrintString()); } catch (Exception ex) { @@ -64,20 +66,23 @@ public class TestUtils { public static void assertMultiReplace(boolean logRep, String fle, String... inps) { if (inps.length < 2) { - throw new IllegalArgumentException("ERROR: Must provide at least two strings to assertMultiReplace"); + throw new IllegalArgumentException( + "ERROR: Must provide at least two strings to assertMultiReplace"); } if (inps.length % 2 != 0) { - throw new IllegalArgumentException("ERROR: Odd number of strings passed to assertMultiReplace"); + throw new IllegalArgumentException( + "ERROR: Odd number of strings passed to assertMultiReplace"); } List<ReplPair> lrp = null; - try (FileInputStream fis = new FileInputStream(fle); Scanner scn = new Scanner(fis)) { + try (FileInputStream fis = new FileInputStream(fle); + Scanner scn = new Scanner(fis)) { lrp = ReplPair.readList(scn); } catch (BadReplParse rpex) { System.err.println(rpex.toPrintString()); - + assertTrue(false); } catch (Exception ex) { System.err.println("EXCEPTION"); @@ -90,7 +95,7 @@ public class TestUtils { for (int i = 0; i < inps.length; i += 2) { String right = inps[i]; - String inp = inps[i + 1]; + String inp = inps[i + 1]; assertReplacesTo(logRep, right, lrp, inp); } @@ -104,7 +109,8 @@ public class TestUtils { assertReplacesTo(false, right, rps, inp); } - public static void assertReplacesTo(boolean logRep, String right, List<ReplPair> rps, String inp) { + public static void assertReplacesTo(boolean logRep, String right, List<ReplPair> rps, + String inp) { if (logRep) { System.err.printf("\t[LOG] Checking '%s' -> '%s'\n", inp, right); } @@ -124,13 +130,16 @@ public class TestUtils { assertEquals(right, tmp); } - public static void assertSplitsTo(String inp, String esc, String splat, String... right) { + public static void assertSplitsTo(String inp, String esc, String splat, + String... right) { assertSplitsTo(false, inp, esc, splat, right); } - public static void assertSplitsTo(boolean doLog, String inp, String esc, String splat, String... right) { + public static void assertSplitsTo(boolean doLog, String inp, String esc, String splat, + String... right) { try { - if (doLog) StringUtils.isDebug = true; + if (doLog) + StringUtils.isDebug = true; String[] lst = StringUtils.escapeSplit(esc, splat, inp); @@ -152,7 +161,8 @@ public class TestUtils { assertTrue(false); } finally { - if (doLog) StringUtils.isDebug = false; + if (doLog) + StringUtils.isDebug = false; } } @@ -160,8 +170,10 @@ public class TestUtils { assertIsControl(false, inp, strang, args); } - public static void assertIsControl(boolean doLog, String inp, String strang, Control... args) { - ControlledString cs = ControlledString.parse(inp, new ParseStrings("//", ";", "/", "|")); + public static void assertIsControl(boolean doLog, String inp, String strang, + Control... args) { + ControlledString cs + = ControlledString.parse(inp, new ParseStrings("//", ";", "/", "|")); if (doLog) { System.err.printf("[LOG] CS: %s\n", cs); |
