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

72 lines
1.5 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();
string[] input = new[]
{
"5",
"256 42",
"1000 1000",
"-1000 1000",
"-1000 1000",
"20 22"
};
IOTester.SetInput(input);
Program.Main();
string[] expectedOutput = new[]
{
"298",
"2000",
"0",
"0",
"42"
};
string[] actualOutput = IOTester.GetOutputLines();
Assert.Equal(expectedOutput.Length, actualOutput.Length);
for (int i = 0; i < expectedOutput.Length; i++)
{
Assert.Equal(expectedOutput[i], actualOutput[i]);
}
}
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-08-10 14:17:08 +03:00
string[] expectedOutput = File.ReadLines(output).ToArray();
2023-08-09 09:42:50 +03:00
string[] actualOutput = IOTester.GetOutputLines();
2023-08-09 17:06:42 +03:00
Assert.Equal(expectedOutput.Length, actualOutput.Length);
for (int i = 0; i < expectedOutput.Length; i++)
2023-08-09 09:42:50 +03:00
{
2023-08-09 17:06:42 +03:00
Assert.Equal(expectedOutput[i], actualOutput[i]);
2023-08-09 09:42:50 +03:00
}
}
2023-08-10 14:17:08 +03:00
}
public class FileNameGenerator : IEnumerable<object[]>
{
private readonly string inputFolder = @"..\..\..\Input";
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);
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
}