/** Test of getWord method, of class PdfWord. */ @Test public void testGetWord() { instance.setWord("test word"); assertEquals(instance.getWord(), "test word"); instance.setWord(""); assertEquals(instance.getWord(), ""); }
/** Test of setSoftBreak method, of class PdfWord. */ @Test public void testSetSoftBreak() { PdfWord instanceTmp = new PdfWord(char1); instanceTmp.setSoftBreak(Boolean.TRUE); assertTrue(instanceTmp.isSoftBreak()); instanceTmp.setSoftBreak(Boolean.FALSE); assertFalse(instanceTmp.isSoftBreak()); }
/** Test of toJson method, of class PdfWord. */ @Test public void testConstructor() { PdfWord instanceTmp = new PdfWord(char1); ArrayList<PdfWordPosition> posTmp = instanceTmp.getPositions(); assertEquals(instanceTmp.getWord(), "a"); assertEquals(posTmp.size(), 1); assertEquals(posTmp.get(0).getStart(), char1); assertEquals(posTmp.get(0).getEnd(), char1); }
/** Test of toString method, of class PdfWord. */ @Test public void testToString() { assertEquals(instance.toString(), "a"); instance.setWord("test word"); assertEquals(instance.toString(), "test word"); instance.setWord(""); assertEquals(instance.toString(), ""); }
/** Test of toJson method, of class PdfWord. */ @Test public void testToJson() { assertTrue(instance.toJson() instanceof JSONObject); String expectedJson = "{\"layout\":[{\"width\":4.0,\"x\":0.0,\"y\":1.1,\"height\":1.1}],\"word\":{\"readable\":\"a\",\"normalised\":\"a\"}}"; StringWriter out = new StringWriter(); try { instance.toJson().writeJSONString(out); assertEquals(out.toString(), expectedJson); } catch (IOException ex) { fail("JSON data mismatch"); } }
/** Test of getLocationStart method, of class PdfWord. */ @Test public void testGetPositions() { ArrayList<PdfWordPosition> posTmp = instance.getPositions(); assertEquals(posTmp.size(), 1); assertEquals(posTmp.get(0).getStart(), char1); assertEquals(posTmp.get(0).getEnd(), char1); }
/** Test of addCharacter method, of class PdfWord. */ @Test public void testAddCharacter() throws IOException { instance.addCharacter(char2); ArrayList<PdfWordPosition> posTmp = instance.getPositions(); assertEquals(instance.getWord(), "ab"); assertEquals(posTmp.size(), 1); assertEquals(posTmp.get(0).getStart(), char1); assertEquals(posTmp.get(0).getEnd(), char2); PdfWord instanceTmp = new PdfWord(char1); PdfCharacter char3 = this.createPdfCharacter("-"); instanceTmp.addCharacter(char3); assertEquals(instanceTmp.getWord(), "a"); instanceTmp.addCharacter(char2); assertEquals(instanceTmp.getWord(), "ab"); }
/** Test of prepWordForSave method, of class PdfWord. */ @Test public void testPrepWordForSave() { assertEquals(instance.prepWordForSave(""), ""); assertEquals(instance.prepWordForSave("az"), "az"); assertEquals(instance.prepWordForSave("AZ"), "AZ"); assertEquals(instance.prepWordForSave("09"), "09"); assertEquals(instance.prepWordForSave("a'b"), "a'b"); assertEquals(instance.prepWordForSave("a'"), "a"); assertNotEquals(instance.prepWordForSave(Character.toString((char) 127)), ""); }