Parse into nested arguments
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
package net.minecraft.commands;
|
||||
|
||||
import net.minecraft.commands.tree.CommandNode;
|
||||
|
||||
public class CommandNodeTest {
|
||||
CommandNode node;
|
||||
|
||||
}
|
||||
@@ -18,7 +18,10 @@ public class IntegerArgumentTypeTest {
|
||||
|
||||
@Test
|
||||
public void testParse() throws Exception {
|
||||
assertThat(type.parse("50"), is(50));
|
||||
CommandArgumentType.CommandArgumentParseResult<Integer> result = type.parse("50");
|
||||
|
||||
assertThat(result.getRaw(), is("50"));
|
||||
assertThat(result.getResult(), is(50));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalCommandArgumentException.class)
|
||||
@@ -33,7 +36,10 @@ public class IntegerArgumentTypeTest {
|
||||
|
||||
@Test
|
||||
public void testParseLowerLimit() throws Exception {
|
||||
assertThat(type.parse("-100"), is(-100));
|
||||
CommandArgumentType.CommandArgumentParseResult<Integer> result = type.parse("-100");
|
||||
|
||||
assertThat(result.getRaw(), is("-100"));
|
||||
assertThat(result.getResult(), is(-100));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalCommandArgumentException.class)
|
||||
@@ -43,6 +49,9 @@ public class IntegerArgumentTypeTest {
|
||||
|
||||
@Test
|
||||
public void testParseHigherLimit() throws Exception {
|
||||
assertThat(type.parse("100"), is(100));
|
||||
CommandArgumentType.CommandArgumentParseResult<Integer> result = type.parse("100");
|
||||
|
||||
assertThat(result.getRaw(), is("100"));
|
||||
assertThat(result.getResult(), is(100));
|
||||
}
|
||||
}
|
||||
@@ -24,4 +24,16 @@ public class ArgumentCommandNodeTest {
|
||||
public void testParseInvalid() throws Exception {
|
||||
node.parse("bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseChild() throws Exception {
|
||||
node.addChild(argument("bar", integer()).build());
|
||||
|
||||
node.parse("123 123");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalCommandArgumentException.class)
|
||||
public void testParseNoChildren() throws Exception {
|
||||
node.parse("123 123");
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,9 @@ import net.minecraft.commands.exceptions.IllegalCommandArgumentException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static net.minecraft.commands.arguments.IntegerArgumentType.integer;
|
||||
import static net.minecraft.commands.builder.CommandBuilder.command;
|
||||
import static net.minecraft.commands.builder.RequiredArgumentBuilder.argument;
|
||||
|
||||
public class LiteralCommandNodeTest {
|
||||
LiteralCommandNode node;
|
||||
@@ -23,4 +25,16 @@ public class LiteralCommandNodeTest {
|
||||
public void testParseInvalid() throws Exception {
|
||||
node.parse("bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseChild() throws Exception {
|
||||
node.addChild(argument("bar", integer()).build());
|
||||
|
||||
node.parse("foo 123");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalCommandArgumentException.class)
|
||||
public void testParseNoChildren() throws Exception {
|
||||
node.parse("foo 123");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user