diff options
| author | Muga Nishizawa <muga@f11vm.(none)> | 2010-10-05 20:47:03 +0900 |
|---|---|---|
| committer | Muga Nishizawa <muga@f11vm.(none)> | 2010-10-05 20:47:03 +0900 |
| commit | 28f4bd5a67f06469ed7cf674851635b254fc156a (patch) | |
| tree | 6506243c9dbd1dc3071d85ccb9e2034004cdf73f /java/src | |
| parent | b01c270889a35ebe0b05d4843def94bc95994de5 (diff) | |
| download | msgpack-python-28f4bd5a67f06469ed7cf674851635b254fc156a.tar.gz | |
java: edit test programs for org.msgpack.util.codegen.*
Diffstat (limited to 'java/src')
| -rw-r--r-- | java/src/test/java/org/msgpack/util/codegen/TestDynamicCodeGenPackerConverter.java | 35 | ||||
| -rw-r--r-- | java/src/test/java/org/msgpack/util/codegen/TestDynamicCodeGenPackerUnpacker.java | 35 |
2 files changed, 70 insertions, 0 deletions
diff --git a/java/src/test/java/org/msgpack/util/codegen/TestDynamicCodeGenPackerConverter.java b/java/src/test/java/org/msgpack/util/codegen/TestDynamicCodeGenPackerConverter.java index 54dc43b..5514c27 100644 --- a/java/src/test/java/org/msgpack/util/codegen/TestDynamicCodeGenPackerConverter.java +++ b/java/src/test/java/org/msgpack/util/codegen/TestDynamicCodeGenPackerConverter.java @@ -138,6 +138,13 @@ public class TestDynamicCodeGenPackerConverter extends TestCase { src.f2.add("e1"); src.f2.add("e2"); src.f2.add("e3"); + src.f3 = new ArrayList<List<String>>(); + src.f3.add(src.f2); + src.f4 = new ArrayList<SampleListNestedType>(); + SampleListNestedType slnt = new SampleListNestedType(); + slnt.f0 = new byte[] { 0x01, 0x02 }; + slnt.f1 = "muga"; + src.f4.add(slnt); ByteArrayOutputStream out = new ByteArrayOutputStream(); MessagePacker packer = DynamicCodeGenPacker .create(SampleListTypes.class); @@ -158,6 +165,23 @@ public class TestDynamicCodeGenPackerConverter extends TestCase { for (int i = 0; i < src.f2.size(); ++i) { assertEquals(src.f2.get(i), dst.f2.get(i)); } + assertEquals(src.f3.size(), dst.f3.size()); + for (int i = 0; i < src.f3.size(); ++i) { + List<String> srclist = src.f3.get(i); + List<String> dstlist = dst.f3.get(i); + assertEquals(srclist.size(), dstlist.size()); + for (int j = 0; j < srclist.size(); ++j) { + assertEquals(srclist.get(j), dstlist.get(j)); + } + } + assertEquals(src.f4.size(), dst.f4.size()); + for (int i = 0; i < src.f4.size(); ++i) { + SampleListNestedType s = src.f4.get(i); + SampleListNestedType d = dst.f4.get(i); + assertEquals(s.f0[0], d.f0[0]); + assertEquals(s.f0[1], d.f0[1]); + assertEquals(s.f1, d.f1); + } assertFalse(it.hasNext()); } @@ -165,11 +189,22 @@ public class TestDynamicCodeGenPackerConverter extends TestCase { public List<Integer> f0; public List<Integer> f1; public List<String> f2; + public List<List<String>> f3; + public List<SampleListNestedType> f4; public SampleListTypes() { } } + @MessagePackMessage + public static class SampleListNestedType { + public byte[] f0; + public String f1; + + public SampleListNestedType() { + } + } + public void testMapTypes() throws Exception { SampleMapTypes src = new SampleMapTypes(); src.f0 = new HashMap<Integer, Integer>(); diff --git a/java/src/test/java/org/msgpack/util/codegen/TestDynamicCodeGenPackerUnpacker.java b/java/src/test/java/org/msgpack/util/codegen/TestDynamicCodeGenPackerUnpacker.java index 104194e..7876c7f 100644 --- a/java/src/test/java/org/msgpack/util/codegen/TestDynamicCodeGenPackerUnpacker.java +++ b/java/src/test/java/org/msgpack/util/codegen/TestDynamicCodeGenPackerUnpacker.java @@ -127,6 +127,13 @@ public class TestDynamicCodeGenPackerUnpacker extends TestCase { src.f2.add("e1"); src.f2.add("e2"); src.f2.add("e3"); + src.f3 = new ArrayList<List<String>>(); + src.f3.add(src.f2); + src.f4 = new ArrayList<SampleListNestedType>(); + SampleListNestedType slnt = new SampleListNestedType(); + slnt.f0 = new byte[] { 0x01, 0x02 }; + slnt.f1 = "muga"; + src.f4.add(slnt); ByteArrayOutputStream out = new ByteArrayOutputStream(); MessagePacker packer = DynamicCodeGenPacker .create(SampleListTypes.class); @@ -143,17 +150,45 @@ public class TestDynamicCodeGenPackerUnpacker extends TestCase { for (int i = 0; i < src.f2.size(); ++i) { assertEquals(src.f2.get(i), dst.f2.get(i)); } + assertEquals(src.f3.size(), dst.f3.size()); + for (int i = 0; i < src.f3.size(); ++i) { + List<String> srclist = src.f3.get(i); + List<String> dstlist = dst.f3.get(i); + assertEquals(srclist.size(), dstlist.size()); + for (int j = 0; j < srclist.size(); ++j) { + assertEquals(srclist.get(j), dstlist.get(j)); + } + } + assertEquals(src.f4.size(), dst.f4.size()); + for (int i = 0; i < src.f4.size(); ++i) { + SampleListNestedType s = src.f4.get(i); + SampleListNestedType d = dst.f4.get(i); + assertEquals(s.f0[0], d.f0[0]); + assertEquals(s.f0[1], d.f0[1]); + assertEquals(s.f1, d.f1); + } } public static class SampleListTypes { public List<Integer> f0; public List<Integer> f1; public List<String> f2; + public List<List<String>> f3; + public List<SampleListNestedType> f4; public SampleListTypes() { } } + @MessagePackMessage + public static class SampleListNestedType { + public byte[] f0; + public String f1; + + public SampleListNestedType() { + } + } + public void testMapTypes() throws Exception { SampleMapTypes src = new SampleMapTypes(); src.f0 = new HashMap<Integer, Integer>(); |
