From 3e5e991e8c7a6f30b224522efeb2dd177d598ffa Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Thu, 25 Oct 2018 19:50:08 -0400 Subject: General work on commands --- .../java/bjc/utils/cli/objects/CommandTest.java | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 base/src/test/java/bjc/utils/cli/objects/CommandTest.java (limited to 'base/src/test/java/bjc/utils/cli/objects/CommandTest.java') diff --git a/base/src/test/java/bjc/utils/cli/objects/CommandTest.java b/base/src/test/java/bjc/utils/cli/objects/CommandTest.java new file mode 100644 index 0000000..129af21 --- /dev/null +++ b/base/src/test/java/bjc/utils/cli/objects/CommandTest.java @@ -0,0 +1,43 @@ +package bjc.utils.cli.objects; + +import static org.junit.Assert.*; + +import org.junit.Test; + +/** + * Test that CLI command objects work correctly. + * + * @author bjculkin + * + */ +public class CommandTest { + + /** + * Test basic things work right. + */ + @Test + public void testBasic() { + Command com = Command.fromString("a b c", 1, "console"); + + assertEquals("a b c", com.full); + assertEquals("a", com.name); + assertEquals("b c", com.remn); + + assertEquals("b", com.trimTo(' ')); + assertEquals("c", com.remn); + } + + /** + * Test regex trimming works right. + */ + @Test + public void testRX() { + Command com = Command.fromString("a try1ZZZtry2ZZtry3", 1, "console"); + + assertEquals("try1", com.trimToRX("Z+")); + assertEquals("try2ZZtry3", com.remn); + + assertEquals("try2", com.trimToRX("Z+")); + assertEquals("try3", com.remn); + } +} -- cgit v1.2.3