From 9bc2da18a95dda4253bca225dc607dc9080b3941 Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 3 Dec 2020 02:51:10 -0800 Subject: [PATCH] :bug: Fix number suggestions when there are following arguments (#122) --- .../CommandSuggestionsTest.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/cloud-core/src/test/java/cloud/commandframework/CommandSuggestionsTest.java b/cloud-core/src/test/java/cloud/commandframework/CommandSuggestionsTest.java index 56f3e9e3..3f023985 100644 --- a/cloud-core/src/test/java/cloud/commandframework/CommandSuggestionsTest.java +++ b/cloud-core/src/test/java/cloud/commandframework/CommandSuggestionsTest.java @@ -23,6 +23,7 @@ // package cloud.commandframework; +import cloud.commandframework.arguments.standard.BooleanArgument; import cloud.commandframework.arguments.standard.EnumArgument; import cloud.commandframework.arguments.standard.IntegerArgument; import cloud.commandframework.arguments.standard.StringArgument; @@ -87,7 +88,8 @@ public class CommandSuggestionsTest { .build()); manager.command(manager.commandBuilder("numbers").argument(IntegerArgument.of("num"))); - + manager.command(manager.commandBuilder("numberswithfollowingargument").argument(IntegerArgument.of("num")) + .argument(BooleanArgument.of("another_argument"))); manager.command(manager.commandBuilder("numberswithmin") .argument(IntegerArgument.newBuilder("num").withMin(5).withMax(100))); @@ -222,6 +224,23 @@ public class CommandSuggestionsTest { Assertions.assertEquals(Arrays.asList("5", "6", "7", "8", "9"), suggestions5); } + @Test + void testNumbersWithFollowingArguments() { + final String input = "numberswithfollowingargument "; + final List suggestions = manager.suggest(new TestCommandSender(), input); + Assertions.assertEquals(Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"), suggestions); + final String input2 = "numberswithfollowingargument 1"; + final List suggestions2 = manager.suggest(new TestCommandSender(), input2); + Assertions.assertEquals(Arrays.asList("1", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19"), suggestions2); + final String input3 = "numberswithfollowingargument -"; + final List suggestions3 = manager.suggest(new TestCommandSender(), input3); + Assertions.assertEquals(Arrays.asList("-1", "-2", "-3", "-4", "-5", "-6", "-7", "-8", "-9"), suggestions3); + final String input4 = "numberswithfollowingargument -1"; + final List suggestions4 = manager.suggest(new TestCommandSender(), input4); + Assertions.assertEquals(Arrays.asList("-1", "-10", "-11", "-12", "-13", "-14", "-15", "-16", "-17", "-18", "-19"), + suggestions4); + } + @Test void testInvalidLiteralThenSpace() { final String input = "test o";