aboutsummaryrefslogtreecommitdiff
path: root/test/org/gnunet/construct/FillParserTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'test/org/gnunet/construct/FillParserTest.java')
-rw-r--r--test/org/gnunet/construct/FillParserTest.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/org/gnunet/construct/FillParserTest.java b/test/org/gnunet/construct/FillParserTest.java
new file mode 100644
index 0000000..115b567
--- /dev/null
+++ b/test/org/gnunet/construct/FillParserTest.java
@@ -0,0 +1,37 @@
1package org.gnunet.construct;
2
3import junit.framework.Assert;
4import org.junit.Test;
5
6/**
7 * ...
8 *
9 * @author Florian Dold
10 */
11public class FillParserTest {
12
13 public static class FillTestMessage implements Message {
14 @FrameSize
15 @UInt32
16 public int size;
17 @FillWith
18 public StringTuple[] strings;
19 }
20
21 @Test
22 public void test_fillParser() {
23 FillTestMessage m = new FillTestMessage();
24 m.strings = new StringTuple[]{new StringTuple("foo", "bar"), new StringTuple("quux", "spam")};
25 Construct.patch(m);
26 System.out.println(m.size);
27 byte[] data = Construct.toBinary(m);
28 Assert.assertEquals(m.size, data.length);
29
30 FillTestMessage m2 = Construct.parseAs(data, FillTestMessage.class);
31
32 Assert.assertEquals(m.strings.length, m2.strings.length);
33
34 Assert.assertEquals(m.strings[0], m2.strings[0]);
35 Assert.assertEquals(m.strings[1], m2.strings[1]);
36 }
37}