From dd72739d3c4b3fc6c0acf488bcc995ba6f78b5b6 Mon Sep 17 00:00:00 2001 From: Lukas Reichwein Date: Mon, 15 Jul 2019 09:06:07 +0200 Subject: [PATCH] Tests 2D-Array to String funtionality, this functionallity was extracted and can now be tested. --- .../ugsbo/matrixcalc/MatrixIOUtilsTest.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/test/java/com/ugsbo/matrixcalc/MatrixIOUtilsTest.java b/src/test/java/com/ugsbo/matrixcalc/MatrixIOUtilsTest.java index d951e03..b01e775 100644 --- a/src/test/java/com/ugsbo/matrixcalc/MatrixIOUtilsTest.java +++ b/src/test/java/com/ugsbo/matrixcalc/MatrixIOUtilsTest.java @@ -1,6 +1,7 @@ package com.ugsbo.matrixcalc; import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import org.junit.Before; @@ -117,4 +118,34 @@ public class MatrixIOUtilsTest { assertArrayEquals("The second row is not correct", expected[1], result[1], 0.1); assertArrayEquals("The thierd row is not correct", expected[2], result[2], 0.1); } + + @Test + public void convertsArrayToString_SingleNumber() { + double[][] matrix = { { 1.0 } }; + String expected = "1.0 \n\n"; + + String result = util.convertsArrayToStringInOrderToDisplayIt(matrix); + + assertEquals("The Strings do not Match", expected, result); + } + + @Test + public void convertsArrayToString_FourNumbersInARow() { + double[][] matrix = { { 1.0, 2.0, 3.0, 4.0 } }; + String expected = "1.0 2.0 3.0 4.0 \n\n"; + + String result = util.convertsArrayToStringInOrderToDisplayIt(matrix); + + assertEquals("The Strings do not Match", expected, result); + } + + @Test + public void convertsArrayToString_FourNumbersInTwoRows() { + double[][] matrix = { { 1.0, 2.0 }, { 3.0, 4.0 } }; + String expected = "1.0 2.0 \n\n3.0 4.0 \n\n"; + + String result = util.convertsArrayToStringInOrderToDisplayIt(matrix); + + assertEquals("The Strings do not Match", expected, result); + } } \ No newline at end of file