Fix timeout testing
This commit is contained in:
parent
854c15111c
commit
b77501ab3c
@ -1,16 +1,14 @@
|
|||||||
using System.Collections;
|
|
||||||
|
|
||||||
namespace Codeforces.Test;
|
namespace Codeforces.Test;
|
||||||
|
|
||||||
public class Tests
|
public class Tests
|
||||||
{
|
{
|
||||||
[Fact(Timeout = 30000)]
|
[Fact(Timeout = 5000)]
|
||||||
public void TestText()
|
public async Task TestFromText()
|
||||||
{
|
{
|
||||||
IOTester.Start();
|
IOTester.Start();
|
||||||
string[] input =
|
string[] input =
|
||||||
[
|
[
|
||||||
"5",
|
"5",
|
||||||
"256 42",
|
"256 42",
|
||||||
"1000 1000",
|
"1000 1000",
|
||||||
"-1000 1000",
|
"-1000 1000",
|
||||||
@ -19,10 +17,10 @@ public class Tests
|
|||||||
];
|
];
|
||||||
|
|
||||||
IOTester.SetInput(input);
|
IOTester.SetInput(input);
|
||||||
Program.Main();
|
await Task.Run(Program.Main);
|
||||||
string[] expected =
|
string[] expected =
|
||||||
[
|
[
|
||||||
"298",
|
"298",
|
||||||
"2000",
|
"2000",
|
||||||
"0",
|
"0",
|
||||||
"0",
|
"0",
|
||||||
@ -32,33 +30,18 @@ public class Tests
|
|||||||
Assert.Equal(expected, actual);
|
Assert.Equal(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory(Timeout = 30000)]
|
[Theory(Timeout = 5000)]
|
||||||
[ClassData(typeof(FileNameGenerator))]
|
[ClassData(typeof(FileNameGenerator))]
|
||||||
public void TestIO(string input, string output)
|
public async Task TestFromFiles(string input, string output)
|
||||||
{
|
{
|
||||||
IOTester.Start();
|
IOTester.Start();
|
||||||
var lines = File.ReadLines(input);
|
var lines = File.ReadLines(input);
|
||||||
IOTester.SetInput(lines.ToArray());
|
IOTester.SetInput(lines.ToArray());
|
||||||
|
|
||||||
Program.Main();
|
await Task.Run(Program.Main);
|
||||||
|
|
||||||
var expectedOutput = File.ReadLines(output);
|
var expectedOutput = File.ReadLines(output);
|
||||||
var actualOutput = IOTester.GetOutputLines();
|
var actualOutput = IOTester.GetOutputLines();
|
||||||
Assert.Equal(expectedOutput, actualOutput);
|
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 Xunit;
|
||||||
global using Codeforces;
|
|
Loading…
Reference in New Issue
Block a user