aboutsummaryrefslogtreecommitdiff
path: root/test/org/gnunet/construct/parsers/IntegerParserTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'test/org/gnunet/construct/parsers/IntegerParserTest.java')
-rw-r--r--test/org/gnunet/construct/parsers/IntegerParserTest.java88
1 files changed, 0 insertions, 88 deletions
diff --git a/test/org/gnunet/construct/parsers/IntegerParserTest.java b/test/org/gnunet/construct/parsers/IntegerParserTest.java
deleted file mode 100644
index e94b74e..0000000
--- a/test/org/gnunet/construct/parsers/IntegerParserTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
1/*
2 This file is part of GNUnet.
3 (C) 2011, 2012 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19 */
20
21package org.gnunet.construct.parsers;
22
23import org.gnunet.construct.*;
24import org.junit.Assert;
25import org.junit.Test;
26
27public class IntegerParserTest {
28 public static class IntTestMessage implements Message {
29 @UInt8
30 public byte test1;
31 @UInt8
32 public int test2;
33 @UInt16
34 public int test3;
35 @Int8
36 byte test4;
37 @Int8
38 byte test5;
39 @Int16
40 byte test6;
41 @Int16
42 byte test7;
43 }
44
45 @Test
46 public void test_UInt8() {
47 byte b = Byte.MIN_VALUE;
48 do {
49 IntTestMessage itm1 = new IntTestMessage();
50 itm1.test1 = b;
51 itm1.test2 = 0;
52 byte[] bbuf = Construct.toBinary(itm1);
53 IntTestMessage itm2 = Construct.parseAs(bbuf, IntTestMessage.class);
54 Assert.assertEquals(itm1.test1, itm2.test1);
55 Assert.assertEquals(itm1.test2, itm2.test2);
56
57 b++;
58 } while (b != Byte.MAX_VALUE);
59 }
60
61 @Test
62 public void test_UInt16() {
63 int i = 0;
64 do {
65 IntTestMessage itm1 = new IntTestMessage();
66 itm1.test3 = i;
67 byte[] bbuf = Construct.toBinary(itm1);
68 IntTestMessage itm2 = Construct.parseAs(bbuf, IntTestMessage.class);
69 Assert.assertEquals(itm1.test3, itm2.test3);
70 i++;
71 } while (i != (1 << 15));
72
73
74 }
75
76 @Test
77 public void test_UInt16_short() {
78 short s = Short.MIN_VALUE;
79 do {
80 IntTestMessage itm1 = new IntTestMessage();
81 itm1.test3 = s;
82 byte[] bbuf = Construct.toBinary(itm1);
83 IntTestMessage itm2 = Construct.parseAs(bbuf, IntTestMessage.class);
84 Assert.assertEquals(itm1.test3, itm2.test3);
85 s++;
86 } while (s != Short.MAX_VALUE);
87 }
88}