From 5f0cc26b405c4161e1c10b63835f0cbb969fcc8a Mon Sep 17 00:00:00 2001 From: Neetika23 <42495275+Neetika23@users.noreply.github.com> Date: Thu, 28 Dec 2023 20:33:02 +0530 Subject: [PATCH] Delete core-java-modules/core-java-arrays-guides/src/test/java/com/baeldung/print2DArrays directory --- .../print2DArrays/Print2DArraysUnitTest.java | 56 ------------------- 1 file changed, 56 deletions(-) delete mode 100644 core-java-modules/core-java-arrays-guides/src/test/java/com/baeldung/print2DArrays/Print2DArraysUnitTest.java diff --git a/core-java-modules/core-java-arrays-guides/src/test/java/com/baeldung/print2DArrays/Print2DArraysUnitTest.java b/core-java-modules/core-java-arrays-guides/src/test/java/com/baeldung/print2DArrays/Print2DArraysUnitTest.java deleted file mode 100644 index dcb027c715..0000000000 --- a/core-java-modules/core-java-arrays-guides/src/test/java/com/baeldung/print2DArrays/Print2DArraysUnitTest.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.baeldung.print2DArrays; - -import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; - -import java.util.Arrays; - -import uk.org.webcompere.systemstubs.jupiter.SystemStub; -import uk.org.webcompere.systemstubs.stream.SystemOut; -import uk.org.webcompere.systemstubs.jupiter.SystemStubsExtension; - -@ExtendWith(SystemStubsExtension.class) -public class Print2DArraysUnitTest { - @SystemStub - private SystemOut systemOut; - - @Test - void whenPrint2D_thenUseNested() { - int[][] myArray = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; - for (int i = 0; i < myArray.length; i++) { - for (int j = 0; j < myArray[i].length; j++) { - System.out.print(myArray[i][j] + " "); - } - System.out.println(); - } - String expectedOutput = "1 2 3 \n4 5 6 \n7 8 9 \n"; - assertThat(systemOut.getLines()).containsExactly(expectedOutput); - } - - @Test - public void whenPrint2D_thenUseStream() { - int[][] myArray = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; - Arrays.stream(myArray) .flatMapToInt(Arrays::stream) .forEach(num -> System.out.print(num + " ")); - String expectedOutput = "1 2 3 4 5 6 7 8 9"; - assertThat(systemOut.getLines()).containsExactly(expectedOutput); - } - - @Test - public void whenPrint2D_thenUseDeepToString() { - int[][] myArray = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; - System.out.println(Arrays.deepToString(myArray)); - String expectedOutput = "[[1, 2, 3], [4, 5, 6], [7, 8, 9]]"; - assertThat(systemOut.getLines()).containsExactly(expectedOutput); - } - - @Test - public void whenPrint2D_thenUseArrayToString() { - int[][] myArray = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; - for (int[] row : myArray) { - System.out.println(Arrays.toString(row)); - } - String expectedOutput = "[1, 2, 3]\n[4, 5, 6]\n[7, 8, 9]\n"; - assertThat(systemOut.getLines()).containsExactly(expectedOutput); - } -} -