Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AbstractCompletionProvider.removeCompletion() removes wrong completion #35

Open
tttwang23 opened this issue Nov 15, 2016 · 0 comments
Open

Comments

@tttwang23
Copy link

Test case:

    @Test
    public void testCompletionRemoval()
    {
        final DefaultCompletionProvider provider1 =
            new DefaultCompletionProvider();
        final ArrayList<Completion> box1 = new ArrayList<Completion>();
        final Completion c1 = new BasicCompletion(provider1, "BAAA");
        final Completion c2 = new BasicCompletion(provider1, "beta");
        final Completion c3 = new ShorthandCompletion(provider1, "BETA", "BETA");
        box1.add(c1);
        box1.add(c2);
        box1.add(c3);
        provider1.addCompletions(box1);
        final DefaultCompletionProvider provider2 =
            new DefaultCompletionProvider();
        final ArrayList<Completion> box2 = new ArrayList<Completion>();
        final Completion c4 = new ShorthandCompletion(provider2, "alpha", "alpha");
        final Completion c5 = new BasicCompletion(provider2, "ALPHA");
        final Completion c6 = new BasicCompletion(provider2, "ZZZZZ");
        box2.add(c4);
        box2.add(c5);
        box2.add(c6);
        provider2.addCompletions(box2);
        // Check we can remove the "BETA" completion.
        Assert.assertTrue(provider1.removeCompletion(c3));
        // Check that the "beta" completion should remain.
        List<Completion> betaList = provider1.getCompletionByInputText("beta");
        Assert.assertEquals(1, betaList.size());
        for (Completion comp : betaList)
        {
            Assert.assertEquals("beta", comp.getInputText());
        }
        // Check we can remove the "ALPHA" completion.
        Assert.assertTrue(provider2.removeCompletion(c5));
        // Check that the "alpha" completion should remain.
        List<Completion> alphaList = provider2.getCompletionByInputText("alpha");
        Assert.assertEquals(1, alphaList.size());
        for (Completion comp : alphaList)
        {
            Assert.assertEquals("alpha", comp.getInputText());
        }
    }
tttwang23 added a commit to tttwang23/AutoComplete that referenced this issue Nov 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant