Skip to content

Commit

Permalink
Add nullPointerException comments and ObjectHelper test code. (#5255)
Browse files Browse the repository at this point in the history
* Add NullPointerException comments for doc.

* Add test code for ObjectHelper.java
  • Loading branch information
ggikko authored and akarnokd committed Apr 1, 2017
1 parent 6c8b0ef commit ba5edc9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/main/java/io/reactivex/Observable.java
Original file line number Diff line number Diff line change
Expand Up @@ -3595,6 +3595,9 @@ public static Observable<Long> timer(long delay, TimeUnit unit) {
* time units to use for {@code delay}
* @param scheduler
* the {@link Scheduler} to use for scheduling the item
* @throws NullPointerException
* if {@code unit} is null, or
* if {@code scheduler} is null
* @return an Observable that emits {@code 0L} after a specified delay, on a specified Scheduler, and then
* completes
* @see <a href="http://reactivex.io/documentation/operators/timer.html">ReactiveX operators documentation: Timer</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,27 @@ public void hashCodeOf() {
}

@Test
public void compare() {
public void verifyPositiveInt() throws Exception{
assertEquals(1, ObjectHelper.verifyPositive(1, "param"));
}

@Test
public void verifyPositiveLong() throws Exception{
assertEquals(1L, ObjectHelper.verifyPositive(1L, "param"));
}

@Test(expected = IllegalArgumentException.class)
public void verifyPositiveIntFail() throws Exception{
assertEquals(-1, ObjectHelper.verifyPositive(-1, "param"));
}

@Test(expected = IllegalArgumentException.class)
public void verifyPositiveLongFail() throws Exception{
assertEquals(-1L, ObjectHelper.verifyPositive(-1L, "param"));
}

@Test
public void compare() {
assertEquals(-1, ObjectHelper.compare(0, 2));
assertEquals(0, ObjectHelper.compare(0, 0));
assertEquals(1, ObjectHelper.compare(2, 0));
Expand Down

0 comments on commit ba5edc9

Please sign in to comment.