aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerghei Cebotari <serghei@cebotari.ru>2023-12-07 22:29:25 +0300
committerSerghei Cebotari <serghei@cebotari.ru>2023-12-07 22:29:25 +0300
commitb77501ab3c50ba65beab31d8a6bbd9e9ce1d9f18 (patch)
treeba2bb9a24251742faf14bc63025de0b63276168d
parent854c15111c733b5ffbe27b9164b90678bf38faed (diff)
Fix timeout testing
-rw-r--r--Codeforces.Test/Tests.cs37
-rw-r--r--Codeforces.Test/Usings.cs3
2 files changed, 11 insertions, 29 deletions
diff --git a/Codeforces.Test/Tests.cs b/Codeforces.Test/Tests.cs
index 9623788..161a779 100644
--- a/Codeforces.Test/Tests.cs
+++ b/Codeforces.Test/Tests.cs
@@ -1,16 +1,14 @@
-using System.Collections;
-
namespace Codeforces.Test;
public class Tests
{
- [Fact(Timeout = 30000)]
- public void TestText()
+ [Fact(Timeout = 5000)]
+ public async Task TestFromText()
{
IOTester.Start();
string[] input =
- [
- "5",
+ [
+ "5",
"256 42",
"1000 1000",
"-1000 1000",
@@ -19,10 +17,10 @@ public class Tests
];
IOTester.SetInput(input);
- Program.Main();
+ await Task.Run(Program.Main);
string[] expected =
- [
- "298",
+ [
+ "298",
"2000",
"0",
"0",
@@ -32,33 +30,18 @@ public class Tests
Assert.Equal(expected, actual);
}
- [Theory(Timeout = 30000)]
+ [Theory(Timeout = 5000)]
[ClassData(typeof(FileNameGenerator))]
- public void TestIO(string input, string output)
+ public async Task TestFromFiles(string input, string output)
{
IOTester.Start();
var lines = File.ReadLines(input);
IOTester.SetInput(lines.ToArray());
- Program.Main();
+ await Task.Run(Program.Main);
var expectedOutput = File.ReadLines(output);
var actualOutput = IOTester.GetOutputLines();
Assert.Equal(expectedOutput, actualOutput);
}
-}
-public class FileNameGenerator : IEnumerable<object[]>
-{
- private readonly string inputFolder = @"../../../Input";
- public IEnumerator<object[]> GetEnumerator()
- {
- foreach (var input in Directory.GetFiles(inputFolder))
- {
- string name = Path.GetFileName(input);
- string output = $"../../../Output/{name}.a";
- yield return new object[] { input, output };
- }
- }
-
- IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
} \ No newline at end of file
diff --git a/Codeforces.Test/Usings.cs b/Codeforces.Test/Usings.cs
index c1ede49..8c927eb 100644
--- a/Codeforces.Test/Usings.cs
+++ b/Codeforces.Test/Usings.cs
@@ -1,2 +1 @@
-global using Xunit;
-global using Codeforces; \ No newline at end of file
+global using Xunit; \ No newline at end of file