コード例 #1
0
  /** 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(), "");
  }
コード例 #2
0
  /** 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());
  }
コード例 #3
0
  /** 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);
  }
コード例 #4
0
  /** 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(), "");
  }
コード例 #5
0
 /** 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");
   }
 }
コード例 #6
0
 /** 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);
 }
コード例 #7
0
  /** 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");
  }
コード例 #8
0
 /** 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)), "");
 }