summaryrefslogtreecommitdiff
path: root/clformat/src/test/java/bjc
diff options
context:
space:
mode:
authorBenjamin J. Culkin <bjculkin@mix.wvu.edu>2018-12-06 21:31:57 -0400
committerBenjamin J. Culkin <bjculkin@mix.wvu.edu>2018-12-06 21:31:57 -0400
commit0aea3b65cc504643183569ad70e55f4f8769ea32 (patch)
tree825a2cf7db47914ce066e4b28588dba3f2cf2f46 /clformat/src/test/java/bjc
parentbdff2bfb7719b5a811fe86f4016900a4cd3a3d52 (diff)
Begin conversion to iterator
Diffstat (limited to 'clformat/src/test/java/bjc')
-rw-r--r--clformat/src/test/java/bjc/utils/test/ioutils/CLTokenizerTest.java47
1 files changed, 47 insertions, 0 deletions
diff --git a/clformat/src/test/java/bjc/utils/test/ioutils/CLTokenizerTest.java b/clformat/src/test/java/bjc/utils/test/ioutils/CLTokenizerTest.java
new file mode 100644
index 0000000..a66ffe1
--- /dev/null
+++ b/clformat/src/test/java/bjc/utils/test/ioutils/CLTokenizerTest.java
@@ -0,0 +1,47 @@
+package bjc.utils.test.ioutils;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import org.junit.Test;
+
+import bjc.utils.ioutils.format.CLTokenizer;
+
+// Static imports
+
+import static java.util.Arrays.asList;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests for CL format strings.
+ *
+ * @author EVE
+ *
+ */
+@SuppressWarnings("javadoc")
+public class CLTokenizerTest {
+ @Test
+ public void testTokenizer() {
+ assertIteratorEquals(tokenize(""), "");
+ assertIteratorEquals(tokenize("hello"), "hello");
+ assertIteratorEquals(tokenize("hello olleh"), "hello olleh");
+ assertIteratorEquals(tokenize("A ~A"), "A ", "~A");
+
+ assertIteratorEquals(tokenize("~3,'0D"), "~3,'0D");
+ assertIteratorEquals(tokenize("~,,'|,2:D"), "~,,'|,2:D");
+ assertIteratorEquals(tokenize("~3,,,' ,2:R"), "~3,,,' ,2:R");
+
+ assertIteratorEquals(tokenize("~@[print level = ~D~]~@[print length = ~D~]"), "~@[", "print level = ", "~D", "~]", "~@[", "print length = ", "~D", "~]");
+ }
+
+ private static Iterator<String> tokenize(String inp) {
+ return new CLTokenizer(inp);
+ }
+
+ private static <T> void assertIteratorEquals(Iterator<T> src, T... vals) {
+ for (T val : vals) {
+ assertEquals(val, src.next());
+ }
+ }
+}