import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import java.util.Arrays; import java.util.Collections; import java.util.List; public class SimpleTest { private static MatrixOrdening ordening; @BeforeClass public static void init() { ordening = new DynamischeMatrixOrdening(); } @Test public void test1() { List matrices = Arrays.asList( new Matrix('A', 50, 10), new Matrix('B', 10, 40), new Matrix('C', 40, 30), new Matrix('D', 30, 5) ); MatrixVermenigvuldiging antw = ordening.minimumVermenigvuldigingen(Collections.unmodifiableList(matrices)); Assert.assertEquals("A(B(CD))", antw.toString()); } @Test public void test2() { List matrices = Arrays.asList( new Matrix('A', 10, 10), new Matrix('B', 10, 20), new Matrix('C', 20, 2), new Matrix('D', 2, 30), new Matrix('E', 30, 10) ); MatrixVermenigvuldiging antw = ordening.minimumVermenigvuldigingen(Collections.unmodifiableList(matrices)); Assert.assertEquals("(A(BC))(DE)", antw.toString()); } @Test public void test3() { List matrices = Arrays.asList( new Matrix('A', 1, 10), new Matrix('B', 10, 20), new Matrix('C', 20, 1) ); MatrixVermenigvuldiging antw = ordening.minimumVermenigvuldigingen(Collections.unmodifiableList(matrices)); Assert.assertEquals("A(BC)", antw.toString()); } @Test public void testOneMatrix(){ List matrices = Arrays.asList( new Matrix('A', 210, 120) ); MatrixVermenigvuldiging antw = ordening.minimumVermenigvuldigingen(Collections.unmodifiableList(matrices)); Assert.assertEquals("A", antw.toString()); } }