OSDN Git Service

toSilk for array
[xerial/xerial-core.git] / src / test / java / org / xerial / silk / SilkWriterTest.java
index 9edf94d..e5e2a82 100644 (file)
@@ -24,7 +24,7 @@
 //--------------------------------------\r
 package org.xerial.silk;\r
 \r
-import static org.junit.Assert.assertTrue;\r
+import static org.junit.Assert.*;\r
 \r
 import java.io.StringReader;\r
 import java.io.StringWriter;\r
@@ -142,4 +142,42 @@ public class SilkWriterTest {
         String s = Lens.toSilk(i);\r
         _logger.info(s);\r
     }\r
+\r
+    @Test\r
+    public void array() throws Exception {\r
+        ArrayList<String> input = new ArrayList<String>();\r
+        input.add("hello");\r
+        input.add("world");\r
+        String s = Lens.toSilk(input);\r
+        _logger.info(s);\r
+    }\r
+\r
+    static class Person {\r
+        public int id;\r
+        public String name;\r
+\r
+        public Person(int id, String name) {\r
+            this.id = id;\r
+            this.name = name;\r
+        }\r
+\r
+    }\r
+\r
+    @Test\r
+    public void objectArray() throws Exception {\r
+\r
+        /*\r
+         * expect\r
+         * <pre>\r
+         * -(id:1, name:leo)\r
+         * -(id:2, name:yui)\r
+         * </pre>\r
+         */\r
+        ArrayList<Person> p = new ArrayList<Person>();\r
+        p.add(new Person(1, "leo"));\r
+        p.add(new Person(2, "yui"));\r
+        String s = Lens.toSilk(p);\r
+        _logger.info(s);\r
+    }\r
+\r
 }\r