Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Jul 3, 2017
2 parents d0ea92b + f4215d1 commit 60f73b6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/main/java/org/cactoos/list/Max.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
*/
package org.cactoos.list;

import java.io.IOException;
import java.util.Iterator;
import java.util.NoSuchElementException;
import org.cactoos.Scalar;

/**
Expand Down Expand Up @@ -65,7 +65,9 @@ public Max(final Iterable<Scalar<T>> items) {
public T value() throws Exception {
final Iterator<Scalar<T>> iter = this.items.iterator();
if (!iter.hasNext()) {
throw new IOException("Iterable is empty");
throw new NoSuchElementException(
"Can't find greater element in an empty iterable"
);
}
T max = iter.next().value();
while (iter.hasNext()) {
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/cactoos/list/Min.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
*/
package org.cactoos.list;

import java.io.IOException;
import java.util.Iterator;
import java.util.NoSuchElementException;
import org.cactoos.Scalar;

/**
Expand Down Expand Up @@ -65,7 +65,9 @@ public Min(final Iterable<Scalar<T>> items) {
public T value() throws Exception {
final Iterator<Scalar<T>> iter = this.items.iterator();
if (!iter.hasNext()) {
throw new IOException("Iterable is empty");
throw new NoSuchElementException(
"Can't find smaller element in an empty iterable"
);
}
T min = iter.next().value();
while (iter.hasNext()) {
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/cactoos/list/MaxTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
*/
package org.cactoos.list;

import java.io.IOException;
import java.util.Collections;
import java.util.NoSuchElementException;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;
Expand All @@ -39,7 +39,7 @@
*/
public final class MaxTest {

@Test(expected = IOException.class)
@Test(expected = NoSuchElementException.class)
public void maxAmongEmptyTest() throws Exception {
new Max<>(() -> Collections.emptyIterator()).value();
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/cactoos/list/MinTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
*/
package org.cactoos.list;

import java.io.IOException;
import java.util.Collections;
import java.util.NoSuchElementException;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;
Expand All @@ -39,7 +39,7 @@
*/
public final class MinTest {

@Test(expected = IOException.class)
@Test(expected = NoSuchElementException.class)
public void minAmongEmptyTest() throws Exception {
new Min<>(() -> Collections.emptyIterator()).value();
}
Expand Down

0 comments on commit 60f73b6

Please sign in to comment.