Skip to content

Commit ba5edc9

Browse files
ggikkoakarnokd
authored andcommitted
Add nullPointerException comments and ObjectHelper test code. (ReactiveX#5255)
* Add NullPointerException comments for doc. * Add test code for ObjectHelper.java
1 parent 6c8b0ef commit ba5edc9

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/main/java/io/reactivex/Observable.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3595,6 +3595,9 @@ public static Observable<Long> timer(long delay, TimeUnit unit) {
35953595
* time units to use for {@code delay}
35963596
* @param scheduler
35973597
* the {@link Scheduler} to use for scheduling the item
3598+
* @throws NullPointerException
3599+
* if {@code unit} is null, or
3600+
* if {@code scheduler} is null
35983601
* @return an Observable that emits {@code 0L} after a specified delay, on a specified Scheduler, and then
35993602
* completes
36003603
* @see <a href="http://reactivex.io/documentation/operators/timer.html">ReactiveX operators documentation: Timer</a>

src/test/java/io/reactivex/internal/functions/ObjectHelperTest.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,27 @@ public void hashCodeOf() {
3333
}
3434

3535
@Test
36-
public void compare() {
36+
public void verifyPositiveInt() throws Exception{
37+
assertEquals(1, ObjectHelper.verifyPositive(1, "param"));
38+
}
39+
40+
@Test
41+
public void verifyPositiveLong() throws Exception{
42+
assertEquals(1L, ObjectHelper.verifyPositive(1L, "param"));
43+
}
3744

45+
@Test(expected = IllegalArgumentException.class)
46+
public void verifyPositiveIntFail() throws Exception{
47+
assertEquals(-1, ObjectHelper.verifyPositive(-1, "param"));
48+
}
49+
50+
@Test(expected = IllegalArgumentException.class)
51+
public void verifyPositiveLongFail() throws Exception{
52+
assertEquals(-1L, ObjectHelper.verifyPositive(-1L, "param"));
53+
}
54+
55+
@Test
56+
public void compare() {
3857
assertEquals(-1, ObjectHelper.compare(0, 2));
3958
assertEquals(0, ObjectHelper.compare(0, 0));
4059
assertEquals(1, ObjectHelper.compare(2, 0));

0 commit comments

Comments
 (0)