package test.leecode.string;
import org.junit.Assert;
import org.junit.Test;
import cn.fansunion.leecode.string.FirstUniqueCharacter;
/**
 * @author wen.lei@brgroup.com
 *
 * 2022-2-17
 */
public class FirstUniqueCharacterTest {
    @Test
    public void test() {
        FirstUniqueCharacter fuc = new FirstUniqueCharacter();
        //map
        Assert.assertEquals(2,fuc.firstUniqChar("loveleetcode"));
        Assert.assertEquals(0,fuc.firstUniqChar("abcd"));
        Assert.assertEquals(0,fuc.firstUniqChar("a"));
        Assert.assertEquals(3,fuc.firstUniqChar("abcdabc"));
        Assert.assertEquals(-1,fuc.firstUniqChar("abcdabcd"));
        Assert.assertEquals(-1,fuc.firstUniqChar("abcddcba"));
        Assert.assertEquals(8,fuc.firstUniqChar("abcddcbae"));
        //two list
        Assert.assertEquals(2,fuc.firstUniqCharList("loveleetcode"));
        Assert.assertEquals(0,fuc.firstUniqCharList("abcd"));
        Assert.assertEquals(0,fuc.firstUniqCharList("a"));
        Assert.assertEquals(3,fuc.firstUniqCharList("abcdabc"));
        Assert.assertEquals(-1,fuc.firstUniqCharList("abcdabcd"));
        Assert.assertEquals(-1,fuc.firstUniqCharList("abcddcba"));
        Assert.assertEquals(8,fuc.firstUniqCharList("abcddcbae"));
    }
}
  |