From 9019d4843e6e732d3cbdb7bc0d03a829a11c62b9 Mon Sep 17 00:00:00 2001 From: Ionite Date: Wed, 19 Jul 2023 22:35:14 -0400 Subject: [PATCH] Add ansi parser tests --- StabilityMatrix.Tests/Core/AnsiParserTests.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 StabilityMatrix.Tests/Core/AnsiParserTests.cs diff --git a/StabilityMatrix.Tests/Core/AnsiParserTests.cs b/StabilityMatrix.Tests/Core/AnsiParserTests.cs new file mode 100644 index 00000000..096652b5 --- /dev/null +++ b/StabilityMatrix.Tests/Core/AnsiParserTests.cs @@ -0,0 +1,19 @@ +using StabilityMatrix.Core.Processes; + +namespace StabilityMatrix.Tests.Core; + +[TestClass] +public class AnsiParserTests +{ + [DataTestMethod] + [DataRow("\u001b[0m", "\u001b[0m")] + [DataRow("\u001b[A", "\u001b[A")] + [DataRow("\u001b[A\r\n", "\u001b[A")] + public void TestAnsiRegex(string source, string expectedMatch) + { + var pattern = AnsiParser.AnsiEscapeSequenceRegex(); + var match = pattern.Match(source); + Assert.IsTrue(match.Success); + Assert.AreEqual(expectedMatch, match.Value); + } +}