Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions exercises/practice/matrix/src/test/java/MatrixTest.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

public class MatrixTest {

@Test
@DisplayName("extract row from one number matrix test")
public void extractRowFromOneNumberMatrixTest() {
String matrixAsString = "1";
int rowIndex = 1;
int[] expectedRow = {1};
int[] expectedRow = { 1 };

Matrix matrix = new Matrix(matrixAsString);

assertThat(matrix.getRow(rowIndex)).isEqualTo(expectedRow);
}

@Disabled("Remove to run test")
@DisplayName("extract row from matrix test")
@Test
public void extractRowFromMatrixTest() {
String matrixAsString = "1 2\n3 4";
int rowIndex = 2;
int[] expectedRow = {3, 4};
int[] expectedRow = { 3, 4 };

Matrix matrix = new Matrix(matrixAsString);

Expand All @@ -30,10 +33,11 @@ public void extractRowFromMatrixTest() {

@Disabled("Remove to run test")
@Test
@DisplayName("extract row from diff widths matrix test")
public void extractRowFromDiffWidthsMatrixTest() {
String matrixAsString = "1 2\n10 20";
int rowIndex = 2;
int[] expectedRow = {10, 20};
int[] expectedRow = { 10, 20 };

Matrix matrix = new Matrix(matrixAsString);

Expand All @@ -42,10 +46,11 @@ public void extractRowFromDiffWidthsMatrixTest() {

@Disabled("Remove to run test")
@Test
@DisplayName("extract row from non square matrix test")
public void extractRowFromNonSquareMatrixTest() {
String matrixAsString = "1 2 3\n4 5 6\n7 8 9\n8 7 6";
int rowIndex = 4;
int[] expectedRow = {8, 7, 6};
int[] expectedRow = { 8, 7, 6 };

Matrix matrix = new Matrix(matrixAsString);

Expand All @@ -54,10 +59,11 @@ public void extractRowFromNonSquareMatrixTest() {

@Disabled("Remove to run test")
@Test
@DisplayName("extract column from one number matrix test")
public void extractColumnFromOneNumberMatrixTest() {
String matrixAsString = "1";
int columnIndex = 1;
int[] expectedColumn = {1};
int[] expectedColumn = { 1 };

Matrix matrix = new Matrix(matrixAsString);

Expand All @@ -66,10 +72,11 @@ public void extractColumnFromOneNumberMatrixTest() {

@Disabled("Remove to run test")
@Test
@DisplayName("extract column matrix test")
public void extractColumnMatrixTest() {
String matrixAsString = "1 2 3\n4 5 6\n7 8 9";
int columnIndex = 3;
int[] expectedColumn = {3, 6, 9};
int[] expectedColumn = { 3, 6, 9 };

Matrix matrix = new Matrix(matrixAsString);

Expand All @@ -78,10 +85,11 @@ public void extractColumnMatrixTest() {

@Disabled("Remove to run test")
@Test
@DisplayName("extract column from non square matrix test")
public void extractColumnFromNonSquareMatrixTest() {
String matrixAsString = "1 2 3 4\n5 6 7 8\n9 8 7 6";
int columnIndex = 4;
int[] expectedColumn = {4, 8, 6};
int[] expectedColumn = { 4, 8, 6 };

Matrix matrix = new Matrix(matrixAsString);

Expand All @@ -90,10 +98,11 @@ public void extractColumnFromNonSquareMatrixTest() {

@Disabled("Remove to run test")
@Test
@DisplayName("extract column from diff widths matrix test")
public void extractColumnFromDiffWidthsMatrixTest() {
String matrixAsString = "89 1903 3\n18 3 1\n9 4 800";
int columnIndex = 2;
int[] expectedColumn = {1903, 3, 4};
int[] expectedColumn = { 1903, 3, 4 };

Matrix matrix = new Matrix(matrixAsString);

Expand Down
Loading