AutoComplete icon indicating copy to clipboard operation
AutoComplete copied to clipboard

AbstractCompletionProvider.getCompletionByInputText() result not durable

Open tttwang23 opened this issue 9 years ago • 1 comments

Test case below. The test fails at the second set of checks.

/*
 * 12/14/2016
 *
 * TestDefaultCompletionProvider.java - test basic completion provider implementation.
 * 
 * This library is distributed under a modified BSD license.  See the included
 * AutoComplete.License.txt file for details.
 */


package org.fife.ui.autocomplete;

import java.util.List;

import org.junit.Assert;
import org.junit.runners.MethodSorters;

import org.junit.FixMethodOrder;
import org.junit.Test;



/**
 * Test cases for DefaultCompletionProvider
 *
 * @author Thomas Wang
 */
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestDefaultCompletionProvider extends DefaultCompletionProvider
{

    @Test
    public void testGetCompletionByInputText()
    {
        DefaultCompletionProvider provider = new DefaultCompletionProvider();
        final Completion c1 = new BasicCompletion(provider, "BETA");
        final Completion c2 = new BasicCompletion(provider, "beta");
        final Completion c3 = new BasicCompletion(provider, "ALPHA");
        final Completion c4 = new BasicCompletion(provider, "alpha");
        final Completion c5 = new BasicCompletion(provider, "GAMMA");
        final Completion c6 = new BasicCompletion(provider, "gamma");
        provider.addCompletion(c1);
        provider.addCompletion(c2);
        List<Completion> betaList = provider.getCompletionByInputText("beta");
        // Check for correct properties of returned list.
        Assert.assertTrue(betaList.size() == 2);
        for (Completion comp : betaList)
        {
            Assert.assertTrue("beta".equalsIgnoreCase(comp.getInputText()));
        }
        provider.addCompletion(c3);
        provider.addCompletion(c4);
        provider.addCompletion(c5);
        provider.addCompletion(c6);
        // Check for correct properties of returned list.
        Assert.assertTrue(betaList.size() == 2);
        for (Completion comp : betaList)
        {
            Assert.assertTrue("beta".equalsIgnoreCase(comp.getInputText()));
        }
    }

}

tttwang23 avatar Nov 14 '16 17:11 tttwang23

I have fixed this issue. Working on pull request today.

tttwang23 avatar Nov 15 '16 16:11 tttwang23