1
0
codeforces-template/Codeforces.Test/Tests.cs

64 lines
1.3 KiB
C#
Raw Normal View History

2023-08-10 14:17:08 +03:00
using System.Collections;
2023-08-09 09:42:50 +03:00
namespace Codeforces.Test;
public class Tests
{
2023-08-11 08:04:22 +03:00
[Fact]
public void TestText()
{
IOTester.Start();
2023-12-07 21:44:13 +03:00
string[] input =
[
"5",
2023-08-11 08:04:22 +03:00
"256 42",
"1000 1000",
"-1000 1000",
"-1000 1000",
"20 22"
2023-12-07 21:44:13 +03:00
];
2023-08-11 08:04:22 +03:00
IOTester.SetInput(input);
Program.Main();
2023-12-07 21:44:13 +03:00
string[] expected =
[
"298",
2023-08-11 08:04:22 +03:00
"2000",
"0",
"0",
"42"
2023-12-07 21:44:13 +03:00
];
string[] actual = IOTester.GetOutputLines().ToArray();
Assert.Equal(expected, actual);
2023-08-11 08:04:22 +03:00
}
2023-08-10 14:17:08 +03:00
[Theory]
[ClassData(typeof(FileNameGenerator))]
public void TestIO(string input, string output)
2023-08-09 09:42:50 +03:00
{
IOTester.Start();
2023-08-10 14:17:08 +03:00
var lines = File.ReadLines(input);
2023-08-09 17:06:42 +03:00
IOTester.SetInput(lines.ToArray());
2023-08-09 09:42:50 +03:00
2023-08-09 15:12:39 +03:00
Program.Main();
2023-08-09 09:42:50 +03:00
2023-12-07 21:44:13 +03:00
var expectedOutput = File.ReadLines(output);
var actualOutput = IOTester.GetOutputLines();
Assert.Equal(expectedOutput, actualOutput);
2023-08-09 09:42:50 +03:00
}
2023-08-10 14:17:08 +03:00
}
public class FileNameGenerator : IEnumerable<object[]>
{
2023-08-13 15:49:53 +03:00
private readonly string inputFolder = @"../../../Input";
2023-08-10 14:17:08 +03:00
public IEnumerator<object[]> GetEnumerator()
2023-08-11 08:04:22 +03:00
{
2023-08-10 14:17:08 +03:00
foreach (var input in Directory.GetFiles(inputFolder))
{
string name = Path.GetFileName(input);
2023-08-13 15:49:53 +03:00
string output = $"../../../Output/{name}.a";
2023-08-11 08:04:22 +03:00
yield return new object[] { input, output };
2023-08-10 14:17:08 +03:00
}
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
2023-08-09 09:42:50 +03:00
}