forked from lnsandnkth/java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestLong.java
More file actions
28 lines (23 loc) · 788 Bytes
/
TestLong.java
File metadata and controls
28 lines (23 loc) · 788 Bytes
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
package com.jsoniter.any;
import com.jsoniter.spi.JsonException;
import junit.framework.TestCase;
public class TestLong extends TestCase {
public void test_to_string_should_trim() {
Any any = Any.lazyLong(" 1000".getBytes(), 0, " 1000".length());
assertEquals("1000", any.toString());
}
public void test_should_fail_with_leading_zero() {
byte[] bytes = "01".getBytes();
Any any = Any.lazyLong(bytes, 0, bytes.length);
try {
any.toLong();
fail("This should fail.");
} catch (JsonException e) {
}
}
public void test_should_work_with_zero() {
byte[] bytes = "0".getBytes();
Any any = Any.lazyLong(bytes, 0, bytes.length);
assertEquals(0L, any.toLong());
}
}