// Importieren des Archiv-Files  junit.jar

import java.awt.*;

import java.awt.event.*;
import javax.swing.*;
import java.util.Vector;
import java.io.*;



class MatrixMult {

  public MatrixMult() {
  }


     /*
      Eingangsgrößen:	Matrix A	m ? n
                      Vektor B	n
      Ausgangsgrößen:	Vektor C	m

      Berechnung:		  C = A x B
      */
  public double [] mult(double A[][], double B[] ){
    int i,j,m, n;
    double s;
    double C[];
    m = A.length;
    n = B.length;
    C = new double[m];
    for (i=0; i<m; i++ ) {
    	s = 0;
      for (j=0; j<B.length; j++) {
     		s +=  A[i][j] * B[j];
      }
  	 C[i] = s;
    }
    return C;
  }
}  // class MatrixMult




public class junit4  {

  public junit4() {
  }

  public void test() {
    double A[][];
    double B[];
    double C[];
    MatrixMult m;
    A = new double[3][2];
    B = new double[2];
    double[] CErg = {9.001,12,15};

    Assert assert = new Assert();
    A[0][0]=1;
    A[1][0]=2;
    A[2][0]=3;
    A[0][1]=4;
    A[1][1]=5;
    A[2][1]=6;

    B[0]=1;
    B[1]=2;
    m = new MatrixMult();
    C = m.mult(A,B);
    for (int i=0; i<C.length; i++ ) {
      System.out.println("Matrix C: "+C[i] );
    }
    for (int i=0; i<C.length; i++ ) {
      assert.assertEquals("Vergleich der Vektoren",C[i],CErg[i]);
    }

  }




  public static void main(String[] args) {
    junit4 klasse = new junit4();
    klasse.test();

    pause();
  }

   private static void pause() {
    try {
      System.in.read();
    }
    catch (IOException e) {
    }
  }  // pause


}  // JUnit3



// Quellcode aus JUnit


/**
 * A set of assert methods.  Messages are only displayed when an assert fails.
 */

class Assert {

  Vector liste;
	/**
	 * Protect constructor since it is a  only class
	 */
	public Assert() {
   liste = new Vector();
	}

	public int getErrorCounts() {
   return liste.size();
	}

	public String getListeToString() {
   return liste.toString();
	}

	public Object[] getListe() {
   return liste.toArray();
	}

	/**
	 * Fails a test with the given message.
	 */
	 public void fail(String message) {
		// throw new AssertionFailedError(message);
    liste.addElement(message);
	}




	/**
	 * Asserts that a condition is true. If it isn't it throws
	 * an AssertionFailedError with the given message.
	 */
	 public void assertTrue(String message, boolean condition) {
		if (!condition)
			fail(message);
	}

	/**
	 * Asserts that a condition is false. If it isn't it throws
	 * an AssertionFailedError with the given message.
	 */
	 public void assertFalse(String message, boolean condition) {
		assertTrue(message, !condition);
	}


	/**
	 * Asserts that two objects are equal. If they are not
	 * an AssertionFailedError is thrown with the given message.
	 */
	 public void assertEquals(String message, Object expected, Object actual) {
		if (expected == null && actual == null)
			return;
		if (expected != null && expected.equals(actual))
			return;
		failNotEquals(message, expected, actual);
	}

	/**
	 * Asserts that two Strings are equal.
	 */
	 public void assertEquals(String message, String expected, String actual) {
		if (expected == null && actual == null)
			return;
		if (expected != null && expected.equals(actual))
			return;
		// throw new ComparisonFailure(message, expected, actual);
		failNotEquals(message, expected, actual);
	}

	/**
	 * Asserts that two doubles are equal concerning a delta.  If they are not
	 * an AssertionFailedError is thrown with the given message.  If the expected
	 * value is infinity then the delta value is ignored.
	 */
	 public void assertEquals(String message, double expected, double actual, double delta) {
		// handle infinity specially since subtracting to infinite values gives NaN and the
		// the following test fails
		if (Double.isInfinite(expected)) {
			if (!(expected == actual))
				failNotEquals(message, new Double(expected), new Double(actual));
		} else if (!(Math.abs(expected-actual) <= delta)) // Because comparison with NaN always returns false
			failNotEquals(message, new Double(expected), new Double(actual));
	}


	/**
	 * Asserts that two doubles are equal concerning a delta.  If they are not
	 * an AssertionFailedError is thrown with the given message.  If the expected
	 * value is infinity then the delta value is ignored.
	 */
	 public void assertEquals(String message, double expected, double actual) {
    if (!(expected == actual)) {
				failNotEquals(message, new Double(expected), new Double(actual));
		} 
	}


	/**
	 * Asserts that two floats are equal concerning a delta. If they are not
	 * an AssertionFailedError is thrown with the given message.  If the expected
	 * value is infinity then the delta value is ignored.
	 */
	 public void assertEquals(String message, float expected, float actual, float delta) {
 		// handle infinity specially since subtracting to infinite values gives NaN and the
		// the following test fails
		if (Float.isInfinite(expected)) {
			if (!(expected == actual))
				failNotEquals(message, new Float(expected), new Float(actual));
		} else if (!(Math.abs(expected-actual) <= delta))
      		failNotEquals(message, new Float(expected), new Float(actual));
	}

	/**
	 * Asserts that two longs are equal. If they are not
	 * an AssertionFailedError is thrown with the given message.
	 */
	 public void assertEquals(String message, long expected, long actual) {
	    assertEquals(message, new Long(expected), new Long(actual));
	}

	/**
	 * Asserts that two booleans are equal. If they are not
	 * an AssertionFailedError is thrown with the given message.
	 */
	 public void assertEquals(String message, boolean expected, boolean actual) {
    		assertEquals(message, new Boolean(expected), new Boolean(actual));
  	}

	/**
	 * Asserts that two bytes are equal. If they are not
	 * an AssertionFailedError is thrown with the given message.
	 */
  	 public void assertEquals(String message, byte expected, byte actual) {
		assertEquals(message, new Byte(expected), new Byte(actual));
	}

	/**
	 * Asserts that two chars are equal. If they are not
	 * an AssertionFailedError is thrown with the given message.
	 */
  	 public void assertEquals(String message, char expected, char actual) {
    		assertEquals(message, new Character(expected), new Character(actual));
  	}

	/**
	 * Asserts that two shorts are equal. If they are not
	 * an AssertionFailedError is thrown with the given message.
	 */
	 public void assertEquals(String message, short expected, short actual) {
    		assertEquals(message, new Short(expected), new Short(actual));
	}

	/**
	 * Asserts that two ints are equal. If they are not
	 * an AssertionFailedError is thrown with the given message.
	 */
  	 public void assertEquals(String message, int expected, int actual) {
		assertEquals(message, new Integer(expected), new Integer(actual));
  	}


	/**
	 * Asserts that an object isn't null. If it is
	 * an AssertionFailedError is thrown with the given message.
	 */
	 public void assertNotNull(String message, Object object) {
		assertTrue(message, object != null);
	}

	/**
	 * Asserts that an object is null.  If it is not
	 * an AssertionFailedError is thrown with the given message.
	 */
	 public void assertNull(String message, Object object) {
		assertTrue(message, object == null);
	}

	/**
	 * Asserts that two objects refer to the same object. If they are not
	 * an AssertionFailedError is thrown with the given message.
	 */
	 public void assertSame(String message, Object expected, Object actual) {
		if (expected == actual)
			return;
		failNotSame(message, expected, actual);
	}

 	/**
 	 * Asserts that two objects refer to the same object. If they are not
 	 * an AssertionFailedError is thrown with the given message.
 	 */
	 public void assertNotSame(String message, Object expected, Object actual) {
		if (expected == actual)
			failSame(message);
	}

	 private void failSame(String message) {
		String formatted= "";
 		if (message != null)
 			formatted= message+" ";
 		fail(formatted+"expected not same");
	}

	 private void failNotSame(String message, Object expected, Object actual) {
		String formatted= "";
		if (message != null)
			formatted= message+" ";
		fail(formatted+"expected same:<"+expected+"> was not:<"+actual+">");
	}

	 private void failNotEquals(String message, Object expected, Object actual) {
		fail(format(message, expected, actual));
	}

	 String format(String message, Object expected, Object actual) {
		String formatted= "";
		if (message != null)
			formatted= message+" ";
		return formatted+"expected:<"+expected+"> but was:<"+actual+">";
	}


}  //  Assert
