package edu.vt.marian.Document; import java.io.*; import java.net.*; import java.util.*; import edu.vt.marian.common.*; // import edu.vt.marian.Document.*; /** Unit tester for EntityMap class. @author Robert France */ public class EntityMapTester { /****** static String testStr1 = "&<"; static String testStr2 = "This is &nother <test> string."; static String testStr3 = "This is Ønothe&rgrave; Ætest♭ string."; static String testStr4 = "ŁØĐÞàáâãāăċä"; ********/ static String testStr1 = "&<"; static String testStr2 = "This is &nother <test> string."; static String testStr3 = "This is anøtheŕ tést♭ string."; static String testStr4 = "ŁØƉÞàáâãāăċäå"; static String failTest1 = "This &string has a spurious amp."; static String failTest2 = "This &string has a spurious ampersand and is more than thirty additional characters long."; static String failTest3 = "This &string has < both > spurious and real &&s."; static String failTest4 = "This string has a b�G5;gus numeric entity."; public static void main(String argv[]) throws Exception { int Err; Debug debug = new Debug("debug.conf", "trace.log", false); EntityMap testMap = new EntityMap(debug); try { BufferedReader inFile = new BufferedReader(new FileReader("ansel_uni_comb.map")); testMap.load(inFile); } catch (IOException e) { System.err.println("Cannot load table."); } PrintWriter pw = new PrintWriter(System.out); BufferedWriter bw = new BufferedWriter(pw); System.out.println("First test: map entities to characters:"); System.out.println(" Input: " + testStr1); System.out.print(" Output: "); testMap.mapStringFromEntities(testStr1, bw); bw.flush(); System.out.println(); System.out.println(); System.out.println("Second test: map characters back to entities:"); System.out.println(" Input: " + testStr4); StringWriter sw = new StringWriter(); BufferedWriter bsw = new BufferedWriter( sw ); testMap.mapStringFromEntities(testStr4, bsw); bsw.flush(); String s0 = sw.toString(); System.out.print(" Interm: " + s0 + " ["); for (int i=0; i