Fix timeout testing
This commit is contained in:
parent
854c15111c
commit
b77501ab3c
@ -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();
|
||||
}
|
@ -1,2 +1 @@
|
||||
global using Xunit;
|
||||
global using Codeforces;
|
||||
global using Xunit;
|
Loading…
Reference in New Issue
Block a user