TextFragment#equals(Object) ignores difference in inline code positions

Create issue
Issue #1048 resolved
Kuro Kurosaka (BH Lab) created an issue

TextFragment#equals(Object) returns true if the a TextFragment that uses the same codes but at different positions, and each code’s data is an empty string.

As a result, the following test case fails:

    @Test
    public void testEqualsOnTextWithSameCodesAtDifferentPlaces() {
        TextFragment tf1 = new TextFragment();
        tf1.append(TagType.OPENING, "b", "");
        tf1.append("A");
        tf1.append(TagType.CLOSING, "b", "");
        tf1.append("B");

        TextFragment tf2 = new TextFragment();
        tf2.append("A");
        tf2.append(TagType.OPENING, "b", "");
        tf2.append("B");
        tf2.append(TagType.CLOSING, "b", "");
        assertFalse(tf1.equals(tf2));
    }

Note: Code’s data can be an empty string in the situation like this in .tmx file, for example:

<seg>This is a <bpt/>test<ept/>.</seg>

Comments (2)

  1. Log in to comment