From 3826c5b8e699b7d1ed95a4ae1cbe9997a5455626 Mon Sep 17 00:00:00 2001 From: Andrei Branza Date: Thu, 11 Apr 2024 17:04:01 +0300 Subject: [PATCH] Andrei Branza - removed old code from old module --- .../WriteVsPrintUnitTest.java | 113 ------------------ 1 file changed, 113 deletions(-) delete mode 100644 core-java-modules/core-java-io-apis-2/src/test/java/com/baeldung/printwriterwritevsprint/WriteVsPrintUnitTest.java diff --git a/core-java-modules/core-java-io-apis-2/src/test/java/com/baeldung/printwriterwritevsprint/WriteVsPrintUnitTest.java b/core-java-modules/core-java-io-apis-2/src/test/java/com/baeldung/printwriterwritevsprint/WriteVsPrintUnitTest.java deleted file mode 100644 index ad9c0f4619..0000000000 --- a/core-java-modules/core-java-io-apis-2/src/test/java/com/baeldung/printwriterwritevsprint/WriteVsPrintUnitTest.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.baeldung.printwriterwritevsprint; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -import java.io.*; -import java.util.*; - -import static org.junit.jupiter.api.Assertions.*; - -public class WriteVsPrintUnitTest { - - Object outputFromPrintWriter; - Object outputFromPrintWriter() { - try (BufferedReader br = new BufferedReader(new FileReader("output.txt"))){ - outputFromPrintWriter = br.readLine(); - } catch (IOException e){ - e.printStackTrace(); - Assertions.fail(); - } - return outputFromPrintWriter; - } - - @Test - void whenUsingWriteInt_thenASCIICharacterIsPrinted() throws FileNotFoundException { - - PrintWriter printWriter = new PrintWriter("output.txt"); - - printWriter.write(48); - printWriter.close(); - - assertEquals("0", outputFromPrintWriter()); - } - - @Test - void whenUsingWriteCharArrayFromOffset_thenCharArrayIsPrinted() throws FileNotFoundException { - - PrintWriter printWriter = new PrintWriter("output.txt"); - - printWriter.write(new char[]{'A','/','&','4','E'}, 1, 4 ); - printWriter.close(); - - assertEquals("/&4E", outputFromPrintWriter()); - } - - @Test - void whenUsingWriteStringFromOffset_thenLengthOfStringIsPrinted() throws FileNotFoundException { - - PrintWriter printWriter = new PrintWriter("output.txt"); - - printWriter.write("StringExample", 6, 7 ); - printWriter.close(); - - assertEquals("Example", outputFromPrintWriter()); - } - - @Test - void whenUsingPrintBoolean_thenStringValueIsPrinted() throws FileNotFoundException { - - PrintWriter printWriter = new PrintWriter("output.txt"); - - printWriter.print(true); - printWriter.close(); - - assertEquals("true", outputFromPrintWriter()); - } - - @Test - void whenUsingPrintChar_thenCharIsPrinted() throws FileNotFoundException { - - PrintWriter printWriter = new PrintWriter("output.txt"); - - printWriter.print('A'); - printWriter.close(); - - assertEquals("A", outputFromPrintWriter()); - } - - @Test - void whenUsingPrintInt_thenValueOfIntIsPrinted() throws FileNotFoundException { - - PrintWriter printWriter = new PrintWriter("output.txt"); - - printWriter.print(420); - printWriter.close(); - - assertEquals("420", outputFromPrintWriter()); - } - - @Test - void whenUsingPrintString_thenStringIsPrinted() throws FileNotFoundException { - - PrintWriter printWriter = new PrintWriter("output.txt"); - - printWriter.print("RandomString"); - printWriter.close(); - - assertEquals("RandomString", outputFromPrintWriter()); - } - - @Test - void whenUsingPrintObject_thenObjectToStringIsPrinted() throws FileNotFoundException { - - PrintWriter printWriter = new PrintWriter("output.txt"); - - Map example = new HashMap(); - - printWriter.print(example); - printWriter.close(); - - assertEquals(example.toString(), outputFromPrintWriter()); - } -} \ No newline at end of file