@@ -0,0 +1,1881 @@
+/*%0A * Yet Another UserAgent Analyzer%0A * Copyright (C) 2013-2019 Niels Basjes%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * https://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage nl.basjes.parse.useragent.utils;%0A%0Aimport org.antlr.v4.runtime.CommonToken;%0Aimport org.antlr.v4.runtime.ParserRuleContext;%0Aimport org.antlr.v4.runtime.RuleContext;%0Aimport org.antlr.v4.runtime.Token;%0Aimport org.antlr.v4.runtime.tree.ParseTree;%0Aimport org.junit.jupiter.api.Test;%0A%0Aimport java.util.Collections;%0A%0Aimport static org.junit.jupiter.api.Assertions.assertEquals;%0A%0Apublic class TestAntlrUtils %7B%0A%0A    @Test%0A    public void testEdges() %7B%0A        ParserRuleContext context = new ParserRuleContext(null, 42);%0A%0A        ParseTree content = new RuleContext() %7B%0A            @Override%0A            public String getText() %7B%0A                return %22Content%22;%0A            %7D%0A        %7D;%0A        context.children = Collections.singletonList(content);%0A%0A        Token start = new CommonToken(1, %22Start%22);%0A        Token stop = new CommonToken(2, %22Stop%22);%0A%0A        context.start = null;%0A        context.stop = null;%0A        assertEquals(%22Content%22, AntlrUtils.getSourceText(context));%0A%0A        context.start = start;%0A        context.stop = null;%0A        assertEquals(%22Content%22, AntlrUtils.getSourceText(context));%0A%0A        context.start = null;%0A        context.stop = stop;%0A        assertEquals(%22Content%22, AntlrUtils.getSourceText(context));%0A    %7D%0A%0A%7D%0A

Test edges of the AntlrUtils.getSourceText