Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
krzyk committed May 8, 2018
1 parent 241d49f commit 6abff56
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 37 deletions.
6 changes: 1 addition & 5 deletions src/main/java/org/cactoos/iterable/IterableOfBooleans.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
package org.cactoos.iterable;

import org.cactoos.iterator.IteratorOfBooleans;
import org.cactoos.scalar.UncheckedScalar;

/**
* Iterable of boolean values.
Expand All @@ -40,9 +39,6 @@ public final class IterableOfBooleans extends IterableEnvelope<Boolean> {
* @param values Boolean values
*/
public IterableOfBooleans(final boolean... values) {
super(() -> ()
-> new UncheckedScalar<>(() -> new IteratorOfBooleans(values))
.value()
);
super(() -> new IterableOf<>(new IteratorOfBooleans(values)));
}
}
5 changes: 1 addition & 4 deletions src/main/java/org/cactoos/iterable/IterableOfChars.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
package org.cactoos.iterable;

import org.cactoos.iterator.IteratorOfChars;
import org.cactoos.scalar.UncheckedScalar;

/**
* Iterable of characters.
Expand All @@ -40,8 +39,6 @@ public final class IterableOfChars extends IterableEnvelope<Character> {
* @param chars Characters
*/
public IterableOfChars(final char... chars) {
super(() -> ()
-> new UncheckedScalar<>(() -> new IteratorOfChars(chars)).value()
);
super(() -> new IterableOf<>(new IteratorOfChars(chars)));
}
}
25 changes: 10 additions & 15 deletions src/test/java/org/cactoos/iterator/IteratorOfBooleansTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
package org.cactoos.iterator;

import java.util.NoSuchElementException;
import org.hamcrest.CoreMatchers;
import org.hamcrest.MatcherAssert;
import org.hamcrest.core.IsEqual;
import org.junit.Test;

/**
Expand All @@ -42,9 +42,9 @@ public final class IteratorOfBooleansTest {
@Test
public void emptyIteratorDoesNotHaveNext() {
MatcherAssert.assertThat(
"Can't create empty iterator",
"hasNext is true for empty iterator",
new IteratorOfBooleans().hasNext(),
CoreMatchers.equalTo(false)
new IsEqual<>(false)
);
}

Expand All @@ -55,25 +55,20 @@ public void emptyIteratorThrowsException() {

@Test
public void nonEmptyIteratorDoesNotHaveNext() {
final IteratorOfBooleans iterator = new IteratorOfBooleans(true, false);
iterator.next();
iterator.next();
MatcherAssert.assertThat(
"Can't create non empty iterator",
this.iteratorWithFetchedElements().hasNext(),
CoreMatchers.equalTo(false)
"hasNext is true for already traversed iterator",
iterator.hasNext(),
new IsEqual<>(false)
);
}

@Test(expected = NoSuchElementException.class)
public void nonEmptyIteratorThrowsException() {
this.iteratorWithFetchedElements().next();
}

private IteratorOfBooleans iteratorWithFetchedElements() {
final IteratorOfBooleans iterator = new IteratorOfBooleans(
true, false, true
);
iterator.next();
final IteratorOfBooleans iterator = new IteratorOfBooleans(true);
iterator.next();
iterator.next();
return iterator;
}
}
26 changes: 13 additions & 13 deletions src/test/java/org/cactoos/iterator/IteratorOfCharsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
package org.cactoos.iterator;

import java.util.NoSuchElementException;
import org.hamcrest.CoreMatchers;
import org.hamcrest.MatcherAssert;
import org.hamcrest.core.IsEqual;
import org.junit.Test;

/**
Expand All @@ -42,9 +42,9 @@ public final class IteratorOfCharsTest {
@Test
public void emptyIteratorDoesNotHaveNext() {
MatcherAssert.assertThat(
"Can't create empty iterator",
"hasNext is true for empty iterator",
new IteratorOfChars().hasNext(),
CoreMatchers.equalTo(false)
new IsEqual<>(false)
);
}

Expand All @@ -55,25 +55,25 @@ public void emptyIteratorThrowsException() {

@Test
public void nonEmptyIteratorDoesNotHaveNext() {
final IteratorOfChars iterator = new IteratorOfChars(
'a', 'b', 'c'
);
iterator.next();
iterator.next();
iterator.next();
MatcherAssert.assertThat(
"Can't create non empty iterator",
this.iteratorWithFetchedElements().hasNext(),
CoreMatchers.equalTo(false)
"hasNext is true for already traversed iterator",
iterator.hasNext(),
new IsEqual<>(false)
);
}

@Test(expected = NoSuchElementException.class)
public void nonEmptyIteratorThrowsException() {
this.iteratorWithFetchedElements().next();
}

private IteratorOfChars iteratorWithFetchedElements() {
final IteratorOfChars iterator = new IteratorOfChars(
'a', 'b', 'c'
'a'
);
iterator.next();
iterator.next();
iterator.next();
return iterator;
}
}

0 comments on commit 6abff56

Please sign in to comment.