@Test
  public void testResolve3() {
    bottom =
        new AlignedString("<Post class=\"System\" user=\"11-08-adultsUser12\">11-08-adultsUser13");
    top = new AlignedString(bottom);

    top.replace(0, 47, " ");
    after();
    top.replace(1, 19, "John");
    after();

    ImmutableInterval ri = new ImmutableInterval(1, 5);
    Interval i = top.resolve(ri);

    assertEquals(47, i.getStart());
    assertEquals(65, i.getEnd());

    bottom =
        new AlignedString("<Post class=\"System\" user=\"11-08-adultsUser12\">11-08-adultsUser13");
    top = new AlignedString(bottom);

    top.replace(47, 65, "John");
    after();
    top.replace(0, 47, " ");

    ri = new ImmutableInterval(1, 5);
    i = top.resolve(ri);

    assertEquals(47, i.getStart());
    assertEquals(65, i.getEnd());
  }
  /**
   * If we delete and then try to resolve a segment start ends at the start boundary of the deleted
   * segment, we do not want the deleted segment to be included in the resolved interval.
   */
  @Test
  public void testResolve() {
    top.delete(4, 7);

    final ImmutableInterval ri = new ImmutableInterval(3, 4);
    final Interval i = top.resolve(ri);

    assertEquals(1, i.getLength());
  }
  @Test
  public void testResolve2() {
    top.delete(0, 5);
    top.replace(0, 1, "I want a");

    final ImmutableInterval ri = new ImmutableInterval(0, 8);
    final Interval i = top.resolve(ri);

    assertEquals(5, i.getStart());
    assertEquals(6, i.getEnd());
  }
  /**
   * This is how you would expect to do hypenation removal, but it's wrong - use method used in
   * testInsert2. This here will not work, because AlignedString will try to interpolate the start
   * position of the uli interval (18) within the replaced interval (16-22).
   */
  @Test
  @Ignore("Wrong method to do hypenation removal")
  public void testInsert3() {
    //	          0123456789012345678901234567890
    baseString = "This is a hyphen- ated sentence";
    bottom = new AlignedString(baseString);
    top = new AlignedString(bottom);

    top.replace(16, 22, "ated");

    ImmutableInterval uli = new ImmutableInterval(18, 31);
    Interval adi = top.inverseResolve(uli);
    System.out.println("ADI    : " + top.get(adi.getStart(), adi.getEnd()));
    System.out.println("ULI    : " + bottom.get(uli.getStart(), uli.getEnd()));

    assertEquals(" sentence", top.get(adi.getStart(), adi.getEnd()));
  }
  @Test
  public void testReplace2() {
    top.replace(2, 4, "want");
    top.replace(4, 8, "nnahave");

    final StringBuilder topRef = new StringBuilder(baseString);
    topRef.replace(2, 4, "want");
    topRef.replace(4, 8, "nnahave");

    assertEquals(topRef.toString(), top.get());

    final Interval i1 = top.resolve(new ImmutableInterval(2, 11));
    assertEquals(2, i1.getStart());
    assertEquals(6, i1.getEnd());

    final Interval i2 = top.inverseResolve(new ImmutableInterval(i1.getStart(), i1.getEnd()));
    final String replaced = top.get(i2.getStart(), i2.getEnd());

    System.out.println("Inverse resolved: " + i2);

    assertEquals("wannahave", replaced);
    assertEquals(i1.getStart(), i2.getStart());
    assertEquals(i2.getEnd(), i2.getEnd());
  }