From 2f7e2da782af6e2b272ef1a723b55e4ffc52244c Mon Sep 17 00:00:00 2001 From: Serghei Cebotari Date: Thu, 7 Dec 2023 21:44:13 +0300 Subject: Refactoring --- Codeforces.Test/IOTester.cs | 37 ++++++------------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) (limited to 'Codeforces.Test/IOTester.cs') diff --git a/Codeforces.Test/IOTester.cs b/Codeforces.Test/IOTester.cs index 68a0ebb..5834108 100644 --- a/Codeforces.Test/IOTester.cs +++ b/Codeforces.Test/IOTester.cs @@ -1,11 +1,8 @@ namespace Codeforces.Test { - public class IOTester + public class IOTester { - private static readonly TextReader originalStdIn = Console.In; private static StringReader? stdIn; - - private static readonly TextWriter originalStdOut = Console.Out; private static StringWriter? stdOut; public static void Start() @@ -14,14 +11,6 @@ namespace Codeforces.Test Console.SetOut(stdOut); } - public static void End() - { - stdOut = null; - stdIn = null; - Console.SetOut(originalStdOut); - Console.SetIn(originalStdIn); - } - public static void SetInput(params string[] lines) { string input = string.Join(Environment.NewLine, lines); @@ -29,26 +18,12 @@ namespace Codeforces.Test Console.SetIn(stdIn); } - public static string GetOutput() - { - if (stdOut == null) - { - return string.Empty; - } - else - { - return stdOut.ToString(); - } - } - - public static string[] GetOutputLines() - { - return GetOutput().Split(Environment.NewLine).SkipLast(1).ToArray(); - } - - public static IList GetOutputLinesAsList() + public static IEnumerable GetOutputLines() { - return new List(GetOutputLines()); + return stdOut?.ToString() + .Split(Environment.NewLine) + .SkipLast(1) + ?? Enumerable.Empty(); } } } \ No newline at end of file -- cgit v1.2.3