-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added: tests for Function3 ~ Function10
- Loading branch information
Showing
8 changed files
with
298 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/test/java/cc/kevinlee/functional/types/Function10Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package cc.kevinlee.functional.types; | ||
|
||
import org.junit.Test; | ||
|
||
import java.util.function.Function; | ||
|
||
import static cc.kevinlee.testosterone.Testosterone.test; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* @author Lee, Seong Hyun (Kevin) | ||
* @since 2015-05-16 | ||
*/ | ||
public class Function10Test { | ||
|
||
@Test | ||
public void testAndThen() throws Exception { | ||
final Function10<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer> first = (i1, i2, i3, i4, i5, i6, i7, i8, i9, i10) -> i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8 + i9 + i10; | ||
final Function<Integer, String> second = i -> "Answer is " + i; | ||
|
||
final int input1 = 1; | ||
final int input2 = 2; | ||
final int input3 = 3; | ||
final int input4 = 4; | ||
final int input5 = 5; | ||
final int input6 = 6; | ||
final int input7 = 7; | ||
final int input8 = 8; | ||
final int input9 = 9; | ||
final int input10 = 10; | ||
test("Function10.andThen(Function)", "f10.andThen(f) should apply f10.apply(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) then f.apply(f10Result). \n" + | ||
"In other words, f10.andThen(f) == f(f10(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10))") | ||
.when(() -> | ||
first.andThen(second).apply(input1, input2, input3, input4, input5, input6, input7, input8, input9, input10) | ||
) | ||
.then(actual -> | ||
assertThat(actual).isEqualTo(second.apply(first.apply(input1, input2, input3, input4, input5, input6, input7, input8, input9, input10))) | ||
); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/test/java/cc/kevinlee/functional/types/Function3Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package cc.kevinlee.functional.types; | ||
|
||
import org.junit.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.function.Function; | ||
|
||
import static cc.kevinlee.testosterone.Testosterone.test; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* @author Lee, Seong Hyun (Kevin) | ||
* @since 2015-05-16 | ||
*/ | ||
public class Function3Test { | ||
|
||
@Test | ||
public void testAndThen() throws Exception { | ||
|
||
final Function3<Integer, Integer, Integer, Integer> first = (i1, i2, i3) -> i1 + i2 + i3; | ||
final Function<Integer, String> second = i -> "Answer is " + i; | ||
|
||
final int input1 = 1; | ||
final int input2 = 2; | ||
final int input3 = 3; | ||
test("Function3.andThen(Function)", "f3.andThen(f) should apply f3.apply(p1, p2, p3) then f.apply(f3Result). \n" + | ||
"In other words, f3.andThen(f) == f(f3(p1, p2, p3))") | ||
.when(() -> | ||
first.andThen(second).apply(input1, input2, input3) | ||
) | ||
.then(actual -> | ||
assertThat(actual).isEqualTo(second.apply(first.apply(input1, input2, input3))) | ||
); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/test/java/cc/kevinlee/functional/types/Function4Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package cc.kevinlee.functional.types; | ||
|
||
import org.junit.Test; | ||
|
||
import java.util.function.Function; | ||
|
||
import static cc.kevinlee.testosterone.Testosterone.test; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* @author Lee, Seong Hyun (Kevin) | ||
* @since 2015-05-16 | ||
*/ | ||
public class Function4Test { | ||
|
||
@Test | ||
public void testAndThen() throws Exception { | ||
final Function4<Integer, Integer, Integer, Integer, Integer> first = (i1, i2, i3, i4) -> i1 + i2 + i3 + i4; | ||
final Function<Integer, String> second = i -> "Answer is " + i; | ||
|
||
final int input1 = 1; | ||
final int input2 = 2; | ||
final int input3 = 3; | ||
final int input4 = 4; | ||
test("Function4.andThen(Function)", "f4.andThen(f) should apply f4.apply(p1, p2, p3, p4) then f.apply(f4Result). \n" + | ||
"In other words, f4.andThen(f) == f(f4(p1, p2, p3, p4))") | ||
.when(() -> | ||
first.andThen(second).apply(input1, input2, input3, input4) | ||
) | ||
.then(actual -> | ||
assertThat(actual).isEqualTo(second.apply(first.apply(input1, input2, input3, input4))) | ||
); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/test/java/cc/kevinlee/functional/types/Function5Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package cc.kevinlee.functional.types; | ||
|
||
import org.junit.Test; | ||
|
||
import java.util.function.Function; | ||
|
||
import static cc.kevinlee.testosterone.Testosterone.test; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* @author Lee, Seong Hyun (Kevin) | ||
* @since 2015-05-16 | ||
*/ | ||
public class Function5Test { | ||
|
||
@Test | ||
public void testAndThen() throws Exception { | ||
final Function5<Integer, Integer, Integer, Integer, Integer, Integer> first = (i1, i2, i3, i4, i5) -> i1 + i2 + i3 + i4 + i5; | ||
final Function<Integer, String> second = i -> "Answer is " + i; | ||
|
||
final int input1 = 1; | ||
final int input2 = 2; | ||
final int input3 = 3; | ||
final int input4 = 4; | ||
final int input5 = 5; | ||
test("Function5.andThen(Function)", "f5.andThen(f) should apply f5.apply(p1, p2, p3, p4, p5) then f.apply(f5Result). \n" + | ||
"In other words, f5.andThen(f) == f(f5(p1, p2, p3, p4, p5))") | ||
.when(() -> | ||
first.andThen(second).apply(input1, input2, input3, input4, input5) | ||
) | ||
.then(actual -> | ||
assertThat(actual).isEqualTo(second.apply(first.apply(input1, input2, input3, input4, input5))) | ||
); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/test/java/cc/kevinlee/functional/types/Function6Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package cc.kevinlee.functional.types; | ||
|
||
import org.junit.Test; | ||
|
||
import java.util.function.Function; | ||
|
||
import static cc.kevinlee.testosterone.Testosterone.test; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* @author Lee, Seong Hyun (Kevin) | ||
* @since 2015-05-16 | ||
*/ | ||
public class Function6Test { | ||
|
||
@Test | ||
public void testAndThen() throws Exception { | ||
final Function6<Integer, Integer, Integer, Integer, Integer, Integer, Integer> first = (i1, i2, i3, i4, i5, i6) -> i1 + i2 + i3 + i4 + i5 + i6; | ||
final Function<Integer, String> second = i -> "Answer is " + i; | ||
|
||
final int input1 = 1; | ||
final int input2 = 2; | ||
final int input3 = 3; | ||
final int input4 = 4; | ||
final int input5 = 5; | ||
final int input6 = 6; | ||
test("Function6.andThen(Function)", "f6.andThen(f) should apply f6.apply(p1, p2, p3, p4, p5, p6) then f.apply(f6Result). \n" + | ||
"In other words, f6.andThen(f) == f(f6(p1, p2, p3, p4, p5, p6))") | ||
.when(() -> | ||
first.andThen(second).apply(input1, input2, input3, input4, input5, input6) | ||
) | ||
.then(actual -> | ||
assertThat(actual).isEqualTo(second.apply(first.apply(input1, input2, input3, input4, input5, input6))) | ||
); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/test/java/cc/kevinlee/functional/types/Function7Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package cc.kevinlee.functional.types; | ||
|
||
import org.junit.Test; | ||
|
||
import java.util.function.Function; | ||
|
||
import static cc.kevinlee.testosterone.Testosterone.test; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* @author Lee, Seong Hyun (Kevin) | ||
* @since 2015-05-16 | ||
*/ | ||
public class Function7Test { | ||
|
||
@Test | ||
public void testAndThen() throws Exception { | ||
final Function7<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer> first = (i1, i2, i3, i4, i5, i6, i7) -> i1 + i2 + i3 + i4 + i5 + i6 + i7; | ||
final Function<Integer, String> second = i -> "Answer is " + i; | ||
|
||
final int input1 = 1; | ||
final int input2 = 2; | ||
final int input3 = 3; | ||
final int input4 = 4; | ||
final int input5 = 5; | ||
final int input6 = 6; | ||
final int input7 = 7; | ||
test("Function7.andThen(Function)", "f7.andThen(f) should apply f7.apply(p1, p2, p3, p4, p5, p6, p7) then f.apply(f7Result). \n" + | ||
"In other words, f7.andThen(f) == f(f7(p1, p2, p3, p4, p5, p6, p7))") | ||
.when(() -> | ||
first.andThen(second).apply(input1, input2, input3, input4, input5, input6, input7) | ||
) | ||
.then(actual -> | ||
assertThat(actual).isEqualTo(second.apply(first.apply(input1, input2, input3, input4, input5, input6, input7))) | ||
); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/test/java/cc/kevinlee/functional/types/Function8Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package cc.kevinlee.functional.types; | ||
|
||
import org.junit.Test; | ||
|
||
import java.util.function.Function; | ||
|
||
import static cc.kevinlee.testosterone.Testosterone.test; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* @author Lee, Seong Hyun (Kevin) | ||
* @since 2015-05-16 | ||
*/ | ||
public class Function8Test { | ||
|
||
@Test | ||
public void testAndThen() throws Exception { | ||
final Function8<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer> first = (i1, i2, i3, i4, i5, i6, i7, i8) -> i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8; | ||
final Function<Integer, String> second = i -> "Answer is " + i; | ||
|
||
final int input1 = 1; | ||
final int input2 = 2; | ||
final int input3 = 3; | ||
final int input4 = 4; | ||
final int input5 = 5; | ||
final int input6 = 6; | ||
final int input7 = 7; | ||
final int input8 = 8; | ||
test("Function8.andThen(Function)", "f8.andThen(f) should apply f8.apply(p1, p2, p3, p4, p5, p6, p7, p8) then f.apply(f8Result). \n" + | ||
"In other words, f8.andThen(f) == f(f8(p1, p2, p3, p4, p5, p6, p7, p8))") | ||
.when(() -> | ||
first.andThen(second).apply(input1, input2, input3, input4, input5, input6, input7, input8) | ||
) | ||
.then(actual -> | ||
assertThat(actual).isEqualTo(second.apply(first.apply(input1, input2, input3, input4, input5, input6, input7, input8))) | ||
); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/test/java/cc/kevinlee/functional/types/Function9Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package cc.kevinlee.functional.types; | ||
|
||
import org.junit.Test; | ||
|
||
import java.util.function.Function; | ||
|
||
import static cc.kevinlee.testosterone.Testosterone.test; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* @author Lee, Seong Hyun (Kevin) | ||
* @since 2015-05-16 | ||
*/ | ||
public class Function9Test { | ||
|
||
@Test | ||
public void testAndThen() throws Exception { | ||
final Function9<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer> first = (i1, i2, i3, i4, i5, i6, i7, i8, i9) -> i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8 + i9; | ||
final Function<Integer, String> second = i -> "Answer is " + i; | ||
|
||
final int input1 = 1; | ||
final int input2 = 2; | ||
final int input3 = 3; | ||
final int input4 = 4; | ||
final int input5 = 5; | ||
final int input6 = 6; | ||
final int input7 = 7; | ||
final int input8 = 8; | ||
final int input9 = 9; | ||
test("Function9.andThen(Function)", "f9.andThen(f) should apply f9.apply(p1, p2, p3, p4, p5, p6, p7, p8, p9) then f.apply(f9Result). \n" + | ||
"In other words, f9.andThen(f) == f(f9(p1, p2, p3, p4, p5, p6, p7, p8, p9))") | ||
.when(() -> | ||
first.andThen(second).apply(input1, input2, input3, input4, input5, input6, input7, input8, input9) | ||
) | ||
.then(actual -> | ||
assertThat(actual).isEqualTo(second.apply(first.apply(input1, input2, input3, input4, input5, input6, input7, input8, input9))) | ||
); | ||
} | ||
} |