aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/gnunet/construct/FrameSizeTest.java
blob: 0dc371e62137af8ebfe81fe5e95e31cf9a6026d1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package org.gnunet.construct;

import org.junit.Assert;
import org.junit.Test;

/**
 * ...
 *
 * @author Florian Dold
 */
public class FrameSizeTest {
    public static class CoordMessage implements Message {
        @FrameSize
        @UInt32
        public int size;
        @UInt32
        public int x;
        @UInt8
        public int y;
    }

    public static class RecursiveMessage implements Message {
        @FrameSize
        @UInt32
        public int size;

        @ZeroTerminatedString
        public String data;

        @NestedMessage(newFrame = true, optional = true)
        public RecursiveMessage rec;

    }

    @Test
    public void test_simple() {
        CoordMessage m = new CoordMessage();
        Construct.patch(m);
        Assert.assertEquals(9, m.size);
    }


    //@Test
    public void test_recursive_1() {
        RecursiveMessage rm = new RecursiveMessage();
        rm.data = "foo";
        Construct.patch(rm);
    }
}