Moved tests to correct location

This commit is contained in:
Nathan Adams
2014-09-25 13:11:05 +02:00
parent 78b9216eb4
commit 5136e3d103
9 changed files with 0 additions and 0 deletions
@@ -0,0 +1,43 @@
package net.minecraft.commands.tree;
import net.minecraft.commands.context.CommandContextBuilder;
import net.minecraft.commands.exceptions.IllegalArgumentSyntaxException;
import org.junit.Before;
import org.junit.Test;
import static net.minecraft.commands.arguments.IntegerArgumentType.integer;
import static net.minecraft.commands.builder.RequiredArgumentBuilder.argument;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
public class ArgumentCommandNodeTest {
ArgumentCommandNode node;
CommandContextBuilder contextBuilder;
@Before
public void setUp() throws Exception {
node = argument("foo", integer()).build();
contextBuilder = new CommandContextBuilder();
}
@Test
public void testParse() throws Exception {
assertThat(node.parse("123 456", contextBuilder), is("456"));
assertThat(contextBuilder.getArguments().containsKey("foo"), is(true));
assertThat(contextBuilder.getArguments().get("foo").getResult(), is((Object) 123));
}
@Test
public void testParseExact() throws Exception {
assertThat(node.parse("123", contextBuilder), is(""));
assertThat(contextBuilder.getArguments().containsKey("foo"), is(true));
assertThat(contextBuilder.getArguments().get("foo").getResult(), is((Object) 123));
}
@Test(expected = IllegalArgumentSyntaxException.class)
public void testParseInvalid() throws Exception {
node.parse("foo", contextBuilder);
}
}
@@ -0,0 +1,41 @@
package net.minecraft.commands.tree;
import net.minecraft.commands.context.CommandContextBuilder;
import net.minecraft.commands.exceptions.IllegalArgumentSyntaxException;
import org.junit.Before;
import org.junit.Test;
import static net.minecraft.commands.builder.LiteralArgumentBuilder.literal;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
public class LiteralCommandNodeTest {
LiteralCommandNode node;
CommandContextBuilder contextBuilder;
@Before
public void setUp() throws Exception {
node = literal("foo").build();
contextBuilder = new CommandContextBuilder();
}
@Test
public void testParse() throws Exception {
assertThat(node.parse("foo bar", contextBuilder), is("bar"));
}
@Test
public void testParseExact() throws Exception {
assertThat(node.parse("foo", contextBuilder), is(""));
}
@Test(expected = IllegalArgumentSyntaxException.class)
public void testParseSimilar() throws Exception {
node.parse("foobar", contextBuilder);
}
@Test(expected = IllegalArgumentSyntaxException.class)
public void testParseInvalid() throws Exception {
node.parse("bar", contextBuilder);
}
}
@@ -0,0 +1,23 @@
package net.minecraft.commands.tree;
import net.minecraft.commands.context.CommandContextBuilder;
import org.junit.Before;
import org.junit.Test;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
public class RootCommandNodeTest {
RootCommandNode node;
@Before
public void setUp() throws Exception {
node = new RootCommandNode();
}
@Test
public void testParse() throws Exception {
assertThat(node.parse("foo bar baz", new CommandContextBuilder()), is("foo bar baz"));
}
}