-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCBORDecoderIntegerTest.java
More file actions
67 lines (59 loc) · 2.14 KB
/
Copy pathCBORDecoderIntegerTest.java
File metadata and controls
67 lines (59 loc) · 2.14 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class CBORDecoderIntegerTest extends CBORDecoderTest {
@Test()
public void IntegerTest() throws CBORException {
String input = "1b000000e8d4a51000";
byte[] bytes = fromHex(input);
CBORDecoder decoder = new CBORDecoder();
CBORObject result = decoder.decode(bytes);
assertTrue(result.val instanceof Long);
assertEquals(1000000000000L, result.val);
}
@Test()
public void IntegerTest2() throws CBORException {
String input = "1a000f4240";
byte[] bytes = fromHex(input);
CBORDecoder decoder = new CBORDecoder();
CBORObject result = decoder.decode(bytes);
assertTrue(result.val instanceof Long);
assertEquals(1000000L, result.val);
}
@Test()
public void IntegerTest3() throws CBORException {
String input = "1903e8";
byte[] bytes = fromHex(input);
CBORDecoder decoder = new CBORDecoder();
CBORObject result = decoder.decode(bytes);
assertTrue(result.val instanceof Long);
assertEquals(1000L, result.val);
}
@Test()
public void IntegerTest4() throws CBORException {
String input = "1818";
byte[] bytes = fromHex(input);
CBORDecoder decoder = new CBORDecoder();
CBORObject result = decoder.decode(bytes);
assertTrue(result.val instanceof Long);
assertEquals(24L, result.val);
}
@Test()
public void IntegerTest5() throws CBORException {
String input = "01";
byte[] bytes = fromHex(input);
CBORDecoder decoder = new CBORDecoder();
CBORObject result = decoder.decode(bytes);
assertTrue(result.val instanceof Long);
assertEquals(1L, result.val);
}
@Test()
public void IntegerTest6() throws CBORException {
String input = "00";
byte[] bytes = fromHex(input);
CBORDecoder decoder = new CBORDecoder();
CBORObject result = decoder.decode(bytes);
assertTrue(result.val instanceof Long);
assertEquals(0L, result.val);
}
}