From 0a71730bdcb3d3fa7dedd9116461a53e35fa7328 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Mon, 22 Sep 2014 15:34:15 +0200 Subject: [PATCH] Test for invalid child nodes --- .../minecraft/commands/tree/ArgumentCommandNodeTest.java | 7 +++++++ .../minecraft/commands/tree/LiteralCommandNodeTest.java | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/main/test/net/minecraft/commands/tree/ArgumentCommandNodeTest.java b/src/main/test/net/minecraft/commands/tree/ArgumentCommandNodeTest.java index 486da94..e7f448d 100644 --- a/src/main/test/net/minecraft/commands/tree/ArgumentCommandNodeTest.java +++ b/src/main/test/net/minecraft/commands/tree/ArgumentCommandNodeTest.java @@ -36,6 +36,13 @@ public class ArgumentCommandNodeTest { assertThat(node.parse("123 123"), is(child)); } + @Test(expected = IllegalCommandArgumentException.class) + public void testParseInvalidChild() throws Exception { + node.addChild(argument("bar", integer()).build()); + + node.parse("123 bar"); + } + @Test(expected = IllegalCommandArgumentException.class) public void testParseNoChildren() throws Exception { node.parse("123 123"); diff --git a/src/main/test/net/minecraft/commands/tree/LiteralCommandNodeTest.java b/src/main/test/net/minecraft/commands/tree/LiteralCommandNodeTest.java index d7557b0..72cf6ce 100644 --- a/src/main/test/net/minecraft/commands/tree/LiteralCommandNodeTest.java +++ b/src/main/test/net/minecraft/commands/tree/LiteralCommandNodeTest.java @@ -37,6 +37,13 @@ public class LiteralCommandNodeTest { assertThat(node.parse("foo 123"), is(child)); } + @Test(expected = IllegalCommandArgumentException.class) + public void testParseInvalidChild() throws Exception { + node.addChild(argument("bar", integer()).build()); + + node.parse("foo bar"); + } + @Test(expected = IllegalCommandArgumentException.class) public void testParseNoChildren() throws Exception { node.parse("foo 123");