Skip to content

Commit

Permalink
yegor256#1445: Add one more test to scalar.Repeatead
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriciofx committed Nov 4, 2020
1 parent d764d0b commit 96f391b
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/test/java/org/cactoos/scalar/RepeatedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package org.cactoos.scalar;

import java.util.concurrent.atomic.AtomicInteger;
import org.cactoos.Scalar;
import org.junit.Assert;
import org.junit.jupiter.api.Test;
import org.llorllale.cactoos.matchers.Assertion;
Expand Down Expand Up @@ -73,4 +74,40 @@ void throwsIfZero() {
)
).affirm();
}

@Test
void countFiveTimes() throws Exception {
new Assertion<>(
"Must repeat count 5 times",
new Repeated<>(
new Count(1),
5
),
new ScalarHasValue<>(5)
);
}

/**
* Just a simple count.
* @since 0.48
*/
final class Count implements Scalar<Integer> {
/**
* Number.
*/
private final AtomicInteger num;

/**
* Ctor.
* @param num Number to start to count
*/
Count(final int num) {
this.num = new AtomicInteger(num);
}

@Override
public Integer value() throws Exception {
return this.num.incrementAndGet();
}
}
}

0 comments on commit 96f391b

Please sign in to comment.