File tree 6 files changed +87
-1
lines changed
main/java/net/sf/jsqlparser/expression
test/java/net/sf/jsqlparser/expression
6 files changed +87
-1
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,9 @@ public DoubleValue() {
24
24
}
25
25
26
26
public DoubleValue (final String value ) {
27
+ if (value == null || value .length () == 0 ) {
28
+ throw new IllegalArgumentException ("value can neither be null nor empty." );
29
+ }
27
30
String val = value ;
28
31
if (val .charAt (0 ) == '+' ) {
29
32
val = val .substring (1 );
Original file line number Diff line number Diff line change @@ -26,6 +26,9 @@ public LongValue() {
26
26
}
27
27
28
28
public LongValue (final String value ) {
29
+ if (value == null || value .length () == 0 ) {
30
+ throw new IllegalArgumentException ("value can neither be null nor empty." );
31
+ }
29
32
String val = value ;
30
33
if (val .charAt (0 ) == '+' ) {
31
34
val = val .substring (1 );
Original file line number Diff line number Diff line change @@ -25,6 +25,9 @@ public TimeValue() {
25
25
}
26
26
27
27
public TimeValue (String value ) {
28
+ if (value == null || value .length () == 0 ) {
29
+ throw new IllegalArgumentException ("value can neither be null nor empty." );
30
+ }
28
31
this .value = Time .valueOf (value .substring (1 , value .length () - 1 ));
29
32
}
30
33
Original file line number Diff line number Diff line change
1
+ /*-
2
+ * #%L
3
+ * JSQLParser library
4
+ * %%
5
+ * Copyright (C) 2004 - 2019 JSQLParser
6
+ * %%
7
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
8
+ * #L%
9
+ */
10
+ package net .sf .jsqlparser .expression ;
11
+
12
+ import org .junit .jupiter .api .Test ;
13
+
14
+ import static org .junit .jupiter .api .Assertions .assertThrows ;
15
+
16
+ public class DoubleValueTest {
17
+
18
+ @ Test
19
+ public void testNullValue () {
20
+ assertThrows (IllegalArgumentException .class , () -> {
21
+ new DoubleValue (null );
22
+ });
23
+ }
24
+
25
+ @ Test
26
+ public void testEmptyValue () {
27
+ assertThrows (IllegalArgumentException .class , () -> {
28
+ new DoubleValue ("" );
29
+ });
30
+ }
31
+ }
Original file line number Diff line number Diff line change 11
11
12
12
import java .math .BigInteger ;
13
13
import static org .junit .jupiter .api .Assertions .assertEquals ;
14
+ import static org .junit .jupiter .api .Assertions .assertThrows ;
14
15
import static org .junit .jupiter .api .Assertions .fail ;
15
16
import org .junit .jupiter .api .Test ;
16
17
@@ -39,8 +40,22 @@ public void testLargeNumber() {
39
40
value .getValue ();
40
41
fail ("should not work" );
41
42
} catch (Exception e ) {
42
- //expected to fail
43
+ // expected to fail
43
44
}
44
45
assertEquals (new BigInteger (largeNumber ), value .getBigIntegerValue ());
45
46
}
47
+
48
+ @ Test
49
+ public void testNullStringValue () {
50
+ assertThrows (IllegalArgumentException .class , () -> {
51
+ new LongValue ((String ) null );
52
+ });
53
+ }
54
+
55
+ @ Test
56
+ public void testEmptyStringValue () {
57
+ assertThrows (IllegalArgumentException .class , () -> {
58
+ new LongValue ("" );
59
+ });
60
+ }
46
61
}
Original file line number Diff line number Diff line change
1
+ /*-
2
+ * #%L
3
+ * JSQLParser library
4
+ * %%
5
+ * Copyright (C) 2004 - 2019 JSQLParser
6
+ * %%
7
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
8
+ * #L%
9
+ */
10
+ package net .sf .jsqlparser .expression ;
11
+
12
+ import org .junit .jupiter .api .Test ;
13
+
14
+ import static org .junit .jupiter .api .Assertions .assertThrows ;
15
+
16
+ public class TimeValueTest {
17
+
18
+ @ Test
19
+ public void testNullValue () {
20
+ assertThrows (IllegalArgumentException .class , () -> {
21
+ new TimeValue (null );
22
+ });
23
+ }
24
+
25
+ @ Test
26
+ public void testEmptyValue () {
27
+ assertThrows (IllegalArgumentException .class , () -> {
28
+ new TimeValue ("" );
29
+ });
30
+ }
31
+ }
You can’t perform that action at this time.
0 commit comments