Added TestUtil method that covers redundant test code for former regressions 
tests, i.e. load input strings, decode, load gold, assert equals decoded and 
gold


Project: http://git-wip-us.apache.org/repos/asf/incubator-joshua/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-joshua/commit/89a112a0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-joshua/tree/89a112a0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-joshua/diff/89a112a0

Branch: refs/heads/7_confsystem
Commit: 89a112a07c851cdc9eefb93e5f5d915363031356
Parents: 28f4810
Author: Michael A. Hedderich <michael-al...@users.noreply.github.com>
Authored: Sun Sep 18 18:40:57 2016 +0200
Committer: Michael A. Hedderich <michael-al...@users.noreply.github.com>
Committed: Sun Sep 18 18:40:57 2016 +0200

----------------------------------------------------------------------
 .../org/apache/joshua/decoder/cky/TestUtil.java     | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/89a112a0/joshua-core/src/test/java/org/apache/joshua/decoder/cky/TestUtil.java
----------------------------------------------------------------------
diff --git 
a/joshua-core/src/test/java/org/apache/joshua/decoder/cky/TestUtil.java 
b/joshua-core/src/test/java/org/apache/joshua/decoder/cky/TestUtil.java
index 0855e99..8781092 100644
--- a/joshua-core/src/test/java/org/apache/joshua/decoder/cky/TestUtil.java
+++ b/joshua-core/src/test/java/org/apache/joshua/decoder/cky/TestUtil.java
@@ -14,6 +14,11 @@
  */
 package org.apache.joshua.decoder.cky;
 
+import static com.typesafe.config.ConfigFactory.parseResources;
+import static org.apache.joshua.decoder.cky.TestUtil.decodeList;
+import static org.apache.joshua.decoder.cky.TestUtil.loadStringsFromFile;
+import static org.testng.Assert.assertEquals;
+
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
@@ -35,7 +40,7 @@ public class TestUtil {
   /**
    * Loads a text file and returns a list containing one string per line in 
the file.
    * 
-   * @param pathToFile
+   * @param pathToFile path to file on disc
    * @return
    * @throws IOException
    */
@@ -77,4 +82,13 @@ public class TestUtil {
     final Sentence sentence = new Sentence(input, 0, decoder.getFlags());
     return decoder.decode(sentence).toString();
   }
+  
+  public static void decodeAndAssertDecodedOutputEqualsGold(String 
pathToInput, Decoder decoder, String pathToGold) throws IOException {
+           List<String> inputStrings = loadStringsFromFile(pathToInput);
+
+           List<String> decodedStrings = decodeList(inputStrings, decoder);
+
+           List<String> goldStrings = loadStringsFromFile(pathToGold);
+           assertEquals(decodedStrings, goldStrings);
+  }
 }

Reply via email to