mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 17:57:38 +00:00
Fixed bug with unclosed quotes
This commit is contained in:
parent
46ba1c7f5b
commit
56fd654eed
@ -74,7 +74,7 @@ public class CommandContext {
|
||||
build.append(' ').append(arg2);
|
||||
}
|
||||
}
|
||||
args = removePortionOfArray(args, i, endIndex, build.toString());
|
||||
if (endIndex < args.length) args = removePortionOfArray(args, i, endIndex, build.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,6 @@ import java.util.HashSet;
|
||||
public class CommandContextTest {
|
||||
final String firstCmdString = "herpderp -opw testers \"mani world\" 'another thing' because something";
|
||||
CommandContext firstCommand;
|
||||
CommandContext secondCommand;
|
||||
|
||||
@Before
|
||||
public void setUpTest(){
|
||||
@ -19,7 +18,7 @@ public class CommandContextTest {
|
||||
firstCommand = new CommandContext(firstCmdString, new HashSet<Character>(Arrays.asList('o', 'w')));
|
||||
} catch (CommandException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
fail("Unexpected exception when creating CommandContext");
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,4 +28,48 @@ public class CommandContextTest {
|
||||
new CommandContext(failingCommand, new HashSet<Character>(Arrays.asList('o', 'w')));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBasicArgs() {
|
||||
String command = firstCommand.getCommand();
|
||||
String argOne = firstCommand.getString(0);
|
||||
String joinedArg = firstCommand.getJoinedStrings(0);
|
||||
assertEquals(command, "herpderp");
|
||||
assertEquals(argOne, "another thing");
|
||||
assertEquals(joinedArg, "another thing because something");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFlags() {
|
||||
assertTrue(firstCommand.hasFlag('p'));
|
||||
assertTrue(firstCommand.hasFlag('o'));
|
||||
assertTrue(firstCommand.hasFlag('w'));
|
||||
assertEquals(firstCommand.getFlag('o'), "testers");
|
||||
assertEquals(firstCommand.getFlag('w'), "mani world");
|
||||
assertNull(firstCommand.getFlag('u'));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnlyQuotedString() {
|
||||
String cmd = "r \"hello goodbye have fun\"";
|
||||
String cmd2 = "r 'hellogeedby' nnnnnee";
|
||||
try {
|
||||
CommandContext context = new CommandContext(cmd);
|
||||
CommandContext context2 = new CommandContext(cmd2);
|
||||
} catch (CommandException e) {
|
||||
e.printStackTrace();
|
||||
fail("Error creating CommandContext");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHagingQuoted() {
|
||||
String cmd = "r \"hello goodbye have fun";
|
||||
try {
|
||||
CommandContext context = new CommandContext(cmd);
|
||||
} catch (CommandException e) {
|
||||
e.printStackTrace();
|
||||
fail("Error creating CommandContext");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user