summaryrefslogtreecommitdiff
path: root/sem_5/HLIN505_Java/HLIN505/src/foobar/TestParametreFoo.java
diff options
context:
space:
mode:
authorGaspard Coulet <gaspard.coulet@mines-ales.org>2021-04-28 23:05:53 +0200
committerGaspard Coulet <gaspard.coulet@mines-ales.org>2021-04-28 23:05:53 +0200
commit9fe033ea88c2f705ec18c232873d056e0c229d72 (patch)
tree0647dc8c51610c7336c88c04de2068ea14b21e17 /sem_5/HLIN505_Java/HLIN505/src/foobar/TestParametreFoo.java
Initial commit
Diffstat (limited to 'sem_5/HLIN505_Java/HLIN505/src/foobar/TestParametreFoo.java')
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/foobar/TestParametreFoo.java63
1 files changed, 63 insertions, 0 deletions
diff --git a/sem_5/HLIN505_Java/HLIN505/src/foobar/TestParametreFoo.java b/sem_5/HLIN505_Java/HLIN505/src/foobar/TestParametreFoo.java
new file mode 100644
index 0000000..9b117d5
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/foobar/TestParametreFoo.java
@@ -0,0 +1,63 @@
+package foobar;
+
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import static org.hamcrest.CoreMatchers.is;
+
+@RunWith(Parameterized.class)
+public class TestParametreFoo {
+
+ private static SUT sut;
+ private int x;
+ private int y;
+ private int z;
+ private int t;
+ private int res;
+
+ @Parameters
+ public static Collection data() {
+ return Arrays.asList(new Object[][]{
+ {-1, 3, 5, 2, 3},
+ {5, 5, 5, 2, 5},
+ {5, 5, 3, 2, 5},
+ {3, 3, 5, 2, 3},
+ {3, 3, 3, 2, 3},
+ {1, 5, 3, 2, 5}
+ });
+ }
+
+
+ public TestParametreFoo(int x, int y, int z, int t, int res) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.res = res;
+ this.t=t;
+ }
+
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @Test
+ public void testFoo() {
+ sut=new SUT(x, y, z);
+ assertThat(sut.foo(t), is(res));
+ }
+
+ @Test(expected=FooBarException.class)
+ public void TestFoobarexcept () throws FooBarException {
+ sut=new SUT(-1, 12, 26);
+ sut.foobar();
+ }
+}