package org.nwapw.abacus.tests;

import org.junit.Assert;
import org.junit.Test;
import org.nwapw.abacus.lexing.Lexer;
import org.nwapw.abacus.lexing.pattern.Match;

import java.util.List;

public class LexerTests {

    @Test
    public void testBasicSuccess(){
        Lexer<Integer> lexer = new Lexer<>();
        lexer.register("abc", 0);
        lexer.register("def", 1);
        List<Match<Integer>> matchedIntegers = lexer.lexAll("abcdefabc", 0, Integer::compare);
        Assert.assertEquals(matchedIntegers.get(0).getType(), Integer.valueOf(0));
        Assert.assertEquals(matchedIntegers.get(1).getType(), Integer.valueOf(1));
        Assert.assertEquals(matchedIntegers.get(2).getType(), Integer.valueOf(0));
    }

    @Test
    public void testBasicFailure(){
        Lexer<Integer> lexer = new Lexer<>();
        lexer.register("abc", 0);
        lexer.register("def", 1);
        Assert.assertNull(lexer.lexAll("abcdefabcz", 0, Integer::compare));
    }

}

@@ -964,10 +964,384 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void testNoPatterns()%7B%0A        Lexer%3CInteger%3E lexer = new Lexer%3C%3E();%0A        Assert.assertNull(lexer.lexAll(%22abcdefabc%22, 0, Integer::compare));%0A    %7D%0A%0A    @Test%0A    public void testEmptyMatches()%7B%0A        Lexer%3CInteger%3E lexer = new Lexer%3C%3E();%0A        lexer.register(%22a?%22, 0);%0A        Assert.assertNull(lexer.lexAll(%22%22, 0, Integer::compare));%0A    %7D%0A    %0A
 %7D%0A

Write tests for special cases.