diff --git a/Klausuren/Sd1/2017winter/Solve/src/test/java/de/hdm_stuttgart/mi/sd1/test/ShowReachedPoints.java b/Klausuren/Sd1/2017winter/Solve/src/test/java/de/hdm_stuttgart/mi/sd1/test/ShowReachedPoints.java index 66b4455fccd37b855fc7ccf2bc72e9937f239922..6ebfe9cbfecba7a8daa2d7280adfe9f2a1227460 100644 --- a/Klausuren/Sd1/2017winter/Solve/src/test/java/de/hdm_stuttgart/mi/sd1/test/ShowReachedPoints.java +++ b/Klausuren/Sd1/2017winter/Solve/src/test/java/de/hdm_stuttgart/mi/sd1/test/ShowReachedPoints.java @@ -4,7 +4,7 @@ import de.hdm_stuttgart.mi.exam.unitmarking.RunTests; import de.hdm_stuttgart.mi.sd1.test.aufgabe1.Test_2_FitnessTarifRechner; import de.hdm_stuttgart.mi.sd1.test.aufgabe1.Test_1_Helper; import de.hdm_stuttgart.mi.sd1.test.aufgabe1.Test_3_Maexchen; -import de.hdm_stuttgart.mi.sd1.test.aufgabe2.MaexchenVergleich; +import de.hdm_stuttgart.mi.sd1.test.aufgabe2.Test_MaexchenVergleich; public class ShowReachedPoints { @@ -20,6 +20,6 @@ public class ShowReachedPoints { , Test_1_Helper.class , Test_3_Maexchen.class); - RunTests.exec("Aufgabe 2", MaexchenVergleich.class); + RunTests.exec("Aufgabe 2", Test_MaexchenVergleich.class); } } diff --git a/Klausuren/Sd1/2017winter/Solve/src/test/java/de/hdm_stuttgart/mi/sd1/test/aufgabe2/Test_MaexchenVergleich.java b/Klausuren/Sd1/2017winter/Solve/src/test/java/de/hdm_stuttgart/mi/sd1/test/aufgabe2/Test_MaexchenVergleich.java new file mode 100644 index 0000000000000000000000000000000000000000..7d35f1cc77e04cd540bb2868d42e901626068d4b --- /dev/null +++ b/Klausuren/Sd1/2017winter/Solve/src/test/java/de/hdm_stuttgart/mi/sd1/test/aufgabe2/Test_MaexchenVergleich.java @@ -0,0 +1,143 @@ +package de.hdm_stuttgart.mi.sd1.test.aufgabe2; + + +import de.hdm_stuttgart.mi.sd1.aufgabe2.MaexleWurf; +import org.junit.Assert; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +import de.hdm_stuttgart.mi.exam.unitmarking.ExaminationTestDefaults; +import de.hdm_stuttgart.mi.exam.unitmarking.Marking; + +/** + * Teste Ordnung von Würfelergebnissen beim »Mäxchen« Spiel. + * + */ + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +@SuppressWarnings({"UnusedDeclaration"}) +public class Test_MaexchenVergleich extends ExaminationTestDefaults { + + private static final MaexleWurf[] + nichtSonderFaelle1 = new MaexleWurf[(5 * 6) / 2 - 1], + nichtSonderFaelle2 = new MaexleWurf[(5 * 6) / 2 - 1], + paschFaelle = new MaexleWurf[6], + maexchenFaelle = new MaexleWurf[2]; + + static { + int index = 0; + for (int i = 3; i <= 6; i++) { // 5 + 4 + 3 + 2 + 1 + for (int j = 1; j < i; j++) { + nichtSonderFaelle1[index] = new MaexleWurf(i, j); + nichtSonderFaelle2[index] = new MaexleWurf(j, i); + index++; + } + } + for (int i = 1; i <= 6; i++) { + paschFaelle[i - 1] = new MaexleWurf(i, i); + } + maexchenFaelle[0] = new MaexleWurf(1, 2); + maexchenFaelle[1] = new MaexleWurf(2, 1); + } + + /** + * toString() + */ + @Test @Marking(points = 2) public void test_80() { + Assert.assertEquals("(3|1)", new MaexleWurf(1, 3).toString()); + Assert.assertEquals("(3|1)", new MaexleWurf(3, 1).toString()); + } + + /** + * Gleichheit nicht-Sonderfälle + */ + @Test @Marking(points = 4) public void test_100() { + for (int i = 0; i < nichtSonderFaelle1.length; i++) { + Assert.assertEquals(0, nichtSonderFaelle1[i].compareTo(nichtSonderFaelle1[i])); + Assert.assertEquals(0, nichtSonderFaelle2[i].compareTo(nichtSonderFaelle2[i])); + + Assert.assertEquals(0, nichtSonderFaelle1[i].compareTo(nichtSonderFaelle2[i])); + Assert.assertEquals(0, nichtSonderFaelle2[i].compareTo(nichtSonderFaelle1[i])); + } + } + + /** + * Gleichheit Pasch + */ + @Test @Marking(points = 2) public void test_120() { + for (int i = 1; i <= 6; i++) { + Assert.assertEquals(0, paschFaelle[i - 1].compareTo(new MaexleWurf(i, i))); + } + } + + /** + * Gleichheit Mäxchen + */ + @Test @Marking(points = 2) public void test_140() { + Assert.assertEquals(0, new MaexleWurf(1, 2).compareTo(new MaexleWurf(1, 2))); + Assert.assertEquals(0, new MaexleWurf(1, 2).compareTo(new MaexleWurf(2, 1))); + Assert.assertEquals(0, new MaexleWurf(2, 1).compareTo(new MaexleWurf(1, 2))); + } + + /** + * Ungleichheit Normalfälle untereinander + */ + @Test @Marking(points = 2) public void test_220() { + for (int i = 0; i < nichtSonderFaelle1.length; i++) { + for (int j = i + 1; j < nichtSonderFaelle1.length; j++) { + Assert.assertTrue(0 < nichtSonderFaelle1[i].compareTo(nichtSonderFaelle1[j])); + Assert.assertTrue(0 < nichtSonderFaelle1[i].compareTo(nichtSonderFaelle2[j])); + Assert.assertTrue(0 < nichtSonderFaelle2[i].compareTo(nichtSonderFaelle1[j])); + Assert.assertTrue(0 < nichtSonderFaelle2[i].compareTo(nichtSonderFaelle2[j])); + + Assert.assertTrue(nichtSonderFaelle1[j].compareTo(nichtSonderFaelle1[i]) < 0); + Assert.assertTrue(nichtSonderFaelle1[j].compareTo(nichtSonderFaelle2[i]) < 0); + Assert.assertTrue(nichtSonderFaelle2[j].compareTo(nichtSonderFaelle1[i]) < 0); + Assert.assertTrue(nichtSonderFaelle2[j].compareTo(nichtSonderFaelle2[i]) < 0); + } + } + } + /** + * Ungleichheit Pasch - Normalfall + */ + @Test @Marking(points = 4) public void test_240() { + for (int i = 0; i < nichtSonderFaelle1.length; i++) { + for (final MaexleWurf p : paschFaelle) { + Assert.assertTrue(0 < nichtSonderFaelle1[i].compareTo(p)); + Assert.assertTrue(0 < nichtSonderFaelle2[i].compareTo(p)); + + Assert.assertTrue(p.compareTo(nichtSonderFaelle1[i]) < 0); + Assert.assertTrue(p.compareTo(nichtSonderFaelle2[i]) < 0); + } + } + } + + /** + * Ungleichheit Mäxchen - Normalfall + */ + @Test @Marking(points = 2) public void test_260() { + for (int i = 0; i < nichtSonderFaelle1.length; i++) { + + for (final MaexleWurf m: maexchenFaelle) { + Assert.assertTrue(m.compareTo(nichtSonderFaelle1[i]) < 0); + Assert.assertTrue(m.compareTo(nichtSonderFaelle2[i]) < 0); + + Assert.assertTrue(0 < nichtSonderFaelle1[i].compareTo(m)); + Assert.assertTrue(0 < nichtSonderFaelle2[i].compareTo(m)); + } + } + } + + /** + * Ungleichheit Mäxchen - Pashh + */ + @Test @Marking(points = 2) public void test_280() { + for (final MaexleWurf m: maexchenFaelle) { + for (final MaexleWurf p: paschFaelle) { + Assert.assertTrue(0 < p.compareTo(m)); + Assert.assertTrue(m.compareTo(p) < 0); + } + } + } +}