Skip to content

Commit

Permalink
Added Test_MatrixOperations.java
Browse files Browse the repository at this point in the history
A class that tests and checks the equality of results from all matrix operations that JMatrix currently has.
  • Loading branch information
mitsuki31 authored Jun 18, 2023
1 parent 4a49548 commit bfc4076
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/test/java/com/mitsuki/jmatrix/test/Test_MatrixOperations.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.mitsuki.jmatrix.test;

import com.mitsuki.jmatrix.Matrix;
import com.mitsuki.jmatrix.util.MatrixUtils;

import org.junit.Test;
import static org.junit.Assert.assertEquals;

public class Test_MatrixOperations {
@Test
public void test_MatrixAddition() {
Matrix m = new Matrix(new double[][] {
{ 1, 3, 5 },
{ 5, 7, 4 }
});

Matrix n = new Matrix(new double[][] {
{ 6, 7, -5 },
{ -10, 5, 16 }
});

Matrix res = new Matrix(new double[][] {
{ 7, 10, 0 },
{ -5, 12, 20 }
});

assertEquals(false, MatrixUtils.isNullEntries(m));
assertEquals(false, MatrixUtils.isNullEntries(n));
assertEquals(false, m.equals(n));
assertEquals(false, m.isSquare());

// Check the addition operation
assertEquals(true, Matrix.sum(m, n).equals(res));
}
}

0 comments on commit bfc4076

Please sign in to comment.