Skip to content
Snippets Groups Projects
Commit eaa015d3 authored by Goik Martin's avatar Goik Martin
Browse files

Cleanup

parent 4445609a
No related branches found
No related tags found
No related merge requests found
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 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);
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment