From 9fe033ea88c2f705ec18c232873d056e0c229d72 Mon Sep 17 00:00:00 2001 From: Gaspard Coulet Date: Wed, 28 Apr 2021 23:05:53 +0200 Subject: Initial commit --- .../HLIN505/src/foobar/TestParametreFoo.java | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 sem_5/HLIN505_Java/HLIN505/src/foobar/TestParametreFoo.java (limited to 'sem_5/HLIN505_Java/HLIN505/src/foobar/TestParametreFoo.java') 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(); + } +} -- cgit v1.2.3