From dfa1182d06a9dd2c5071fce63feec9e78ca06e82 Mon Sep 17 00:00:00 2001 From: unsigable Date: Sun, 22 Sep 2024 20:18:10 +0600 Subject: [PATCH] [#278] fixing output 30,31,33 lessons --- modules/35-methods-using/100-methods/Test.java | 7 +++++-- modules/35-methods-using/105-methods-parameters/Test.java | 7 +++++-- modules/35-methods-using/115-string-immutability/Test.java | 7 +++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/modules/35-methods-using/100-methods/Test.java b/modules/35-methods-using/100-methods/Test.java index d07b1112..b1b5fcaf 100644 --- a/modules/35-methods-using/100-methods/Test.java +++ b/modules/35-methods-using/100-methods/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "12"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/35-methods-using/105-methods-parameters/Test.java b/modules/35-methods-using/105-methods-parameters/Test.java index 07e9d0bb..280db672 100644 --- a/modules/35-methods-using/105-methods-parameters/Test.java +++ b/modules/35-methods-using/105-methods-parameters/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "h o d o r"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/35-methods-using/115-string-immutability/Test.java b/modules/35-methods-using/115-string-immutability/Test.java index 285a34bc..f875d6a3 100644 --- a/modules/35-methods-using/115-string-immutability/Test.java +++ b/modules/35-methods-using/115-string-immutability/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "support@hexlet.io"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } }