-
Notifications
You must be signed in to change notification settings - Fork 397
Expand file tree
/
Copy pathTestCastToInt.java
More file actions
89 lines (69 loc) · 1.9 KB
/
TestCastToInt.java
File metadata and controls
89 lines (69 loc) · 1.9 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package sqlancer.pqs.sqlite.cast;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import sqlancer.sqlite3.ast.SQLite3Cast;
import sqlancer.sqlite3.ast.SQLite3Constant;
class TestCastToInt {
@Test
void test1() {
assertBinaryCastToInt("dbb25259", 0);
}
@Test
void test2() {
assertBinaryCastToInt("d9a3", 0);
}
@Test
void test3() {
assertCastStringToInt("1231231922047954197746780200000", Long.MAX_VALUE);
}
@Test
void test4() {
assertCastStringToInt("1231231922047954197746780200000.5", Long.MAX_VALUE);
}
@Test
void test5() {
assertCastStringToInt("-1231231922047954197746780200000.5", Long.MIN_VALUE);
}
@Test
void testSign1() {
assertCastStringToInt("++123", 0);
}
@Test
void testSign2() {
assertCastStringToInt("+123", 123);
}
@Test
void testSign3() {
assertCastStringToInt("-123", -123);
}
@Test
void testSign4() {
assertCastStringToInt("-+123", 0);
}
@Test
void testSign5() {
assertCastStringToInt("+-123", 0);
}
@Test
void testInfinity1() {
assertCastStringToInt("Infinity", 0);
}
@Test
void testInfinity2() {
assertCastStringToInt("-Infinity", 0);
}
@Test
void testNan() {
assertCastStringToInt("NaN", 0);
}
void assertCastStringToInt(String val, long expectedLong) {
SQLite3Constant c = SQLite3Constant.createTextConstant(val);
SQLite3Constant intVal = SQLite3Cast.castToInt(c);
assertEquals(intVal.asInt(), expectedLong);
}
void assertBinaryCastToInt(String val, long expectedLong) {
SQLite3Constant c = SQLite3Constant.createBinaryConstant(val);
SQLite3Constant intVal = SQLite3Cast.castToInt(c);
assertEquals(intVal.asInt(), expectedLong);
}
}