Skip to content

Commit

Permalink
objectionary#2772: ParameterizedTest
Browse files Browse the repository at this point in the history
  • Loading branch information
levBagryansky committed Jan 17, 2024
1 parent f532ab2 commit c9285f9
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions eo-runtime/src/test/java/EOorg/EOeolang/EOerrorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;

import java.util.stream.Stream;

/**
* Test case for {@link EOerror}.
Expand All @@ -62,18 +67,33 @@ void makesToxicObject() {
);
}

@Test
void getsReadableError() {
@ParameterizedTest
@MethodSource("ExternalMethodSource")
void getsReadableError(final Object cnst) {
ExAbstract error = null;
try {
new Dataized(new MyError()).take();
new Dataized(new MyError(cnst)).take();
} catch (final ExAbstract exc) {
error = exc;
}
assert error != null;
MatcherAssert.assertThat(
error.toString(),
Matchers.containsString("qwerty")
Matchers.containsString(cnst.toString())
);
}

/**
* Input arguments for getsReadableError unit test.
* @return Stream of arguments.
*/
private static Stream<Object> ExternalMethodSource() {
return Stream.of(
12345L,
"qwerty",
12.34567D,
true,
false
);
}

Expand All @@ -90,7 +110,7 @@ private static final class MyError extends PhDefault {
/**
* Ctor.
*/
MyError() {
MyError(final Object data) {
this.add(
"φ",
new AtOnce(
Expand All @@ -101,7 +121,7 @@ private static final class MyError extends PhDefault {
Phi.Φ.attr("org").get().attr("eolang").get().attr("error").get()
),
"α",
new Data.ToPhi("qwerty")
new Data.ToPhi(data)
)
)
)
Expand Down

0 comments on commit c9285f9

Please sign in to comment.