All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aliasi.test.unit.util.SgmlTest Maven / Gradle / Ivy

Go to download

This is the original Lingpipe: http://alias-i.com/lingpipe/web/download.html There were not made any changes to the source code.

There is a newer version: 4.1.2-JL1.0
Show newest version
package com.aliasi.test.unit.util;

import com.aliasi.util.Sgml;

import org.junit.Test;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNull;


public class SgmlTest  {

    @Test
    public void test() {
        assertNull(Sgml.entityToCharacter("foobar"));
        assertEquals(Character.valueOf('\u200C'), Sgml.entityToCharacter("zwnj"));

        assertSub("","");
        assertSub("foobar","foobar");
        assertSub("&Agr;","\u0391");
        assertSub("foo&Agr;","foo\u0391");
        assertSub("&Agr;foo","\u0391foo");
        assertSub("foo&Agr;bar","foo\u0391bar");
        assertSub("&Foobar;","?");
        assertSub("ℵ","\u2135");
        assertSub("ℵ´","\u2135\u00B4");
        assertSub("ℵfoo´","\u2135foo\u00B4");
        assertSub("fooℵbar´baz","foo\u2135bar\u00B4baz");
        assertSub("&Foobar;","baz","baz");
    }

    void assertSub(String in, String expected) {
        assertSub(in,expected,null);
    }

    void assertSub(String in, String expected, String unk) {
        assertEquals(expected,
                     unk != null
                     ? Sgml.replaceEntities(in,unk)
                     : Sgml.replaceEntities(in));


    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy