Skip to content

Commit cccf8a2

Browse files
committed
Create ReaderTest.java
1 parent fc7108a commit cccf8a2

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.fasterxml.jackson.core.io.doubleparser;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import java.util.Random;
6+
7+
import static org.junit.jupiter.api.Assertions.assertEquals;
8+
9+
class ReaderTest {
10+
private static final int LEN = 1000;
11+
private static final String[] DOUBLE_STRINGS = new String[LEN];
12+
private static final String[] FLOAT_STRINGS = new String[LEN];
13+
14+
static {
15+
Random rnd = new Random();
16+
for (int i = 0; i < LEN; i++) {
17+
DOUBLE_STRINGS[i] = Double.toString(rnd.nextDouble());
18+
FLOAT_STRINGS[i] = Float.toString(rnd.nextFloat());
19+
}
20+
}
21+
22+
@Test
23+
void verifyDoubles() {
24+
for (int i = 0; i < LEN; i++) {
25+
double fd = FastDoubleParser.parseDouble(DOUBLE_STRINGS[i]);
26+
double jd = Double.parseDouble(DOUBLE_STRINGS[i]);
27+
assertEquals(jd, fd);
28+
}
29+
}
30+
31+
@Test
32+
void verifyFloats() {
33+
for (int i = 0; i < LEN; i++) {
34+
float ff = FastFloatParser.parseFloat(FLOAT_STRINGS[i]);
35+
float jf = Float.parseFloat(FLOAT_STRINGS[i]);
36+
assertEquals(jf, ff);
37+
}
38+
}
39+
40+
}

0 commit comments

Comments
 (0)