Skip to content

Commit

Permalink
Fix nameparser regex issue (#36)
Browse files Browse the repository at this point in the history
* Add failing tests
* Resolve #35
  • Loading branch information
Siphonophora authored Jan 24, 2023
1 parent a783e66 commit 10d5368
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/TestLogger/Core/TestCaseNameParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public class TestCaseNameParser
/// <summary>
/// This one can handle standard formatting with or without method data.
/// </summary>
private static readonly Regex MethodRegex = new (@"^([a-z1-9_.]{1,})\.([a-z1-9_.]{1,})\.(.{1,})$", RegexOptions);
private static readonly Regex MethodRegex = new (@"^([a-z0-9_.]{1,})\.([a-z0-9_.]{1,})\.(.{1,})$", RegexOptions);

/// <summary>
/// Can handle standard formatting with class and method data.
/// </summary>
private static readonly Regex ClassDataRegex = new (@"^([a-z1-9_.]{1,})\.([a-z1-9_.]{1,}\(.{0,}\))\.(.{1,})$", RegexOptions);
private static readonly Regex ClassDataRegex = new (@"^([a-z0-9_.]{1,})\.([a-z0-9_.]{1,}\(.{0,}\))\.(.{1,})$", RegexOptions);

private bool parserErrorReported;

Expand Down
7 changes: 6 additions & 1 deletion test/TestLogger.UnitTests/TestCaseNameParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public class TestCaseNameParserTests
[DataRow("z.y.x.ape.bar('aa\r\nbb',False)", "z.y.x", "ape", "bar('aabb',False)")]
[DataRow("z.y.x.ape.bar('aa\nbb',False)", "z.y.x", "ape", "bar('aabb',False)")]
[DataRow("z.y.x.ape.bar('aa\rbb',False)", "z.y.x", "ape", "bar('aabb',False)")]

[DataRow("NetCore.Tests.NetCoreOnly.Issue28_Examples.ExampleTest2(True,4.8m,4.5m,(4.8, False))", "NetCore.Tests.NetCoreOnly", "Issue28_Examples", "ExampleTest2(True,4.8m,4.5m,(4.8, False))")]
[DataRow("NetCore.Tests.NetCoreOnly.Issue28_Examples(asdf \".\\).ExampleTest2(True,4.8m,4.5m,(4.8, False))", "NetCore.Tests.NetCoreOnly", "Issue28_Examples(asdf \".\\)", "ExampleTest2(True,4.8m,4.5m,(4.8, False))")]
[DataRow("NetCore.Tests.NetCoreOnly.Issue28_Examples(asdf \".\\).ExampleTest2", "NetCore.Tests.NetCoreOnly", "Issue28_Examples(asdf \".\\)", "ExampleTest2")]
Expand All @@ -74,6 +73,12 @@ public class TestCaseNameParserTests
[DataRow("z.a((0,1).b", "z", "a((0,1)", "b")]
[DataRow("z.a(0,1)).b", "z", "a(0,1))", "b")]
[DataRow("z.a(0.21).b", "z", "a(0.21)", "b")]
[DataRow("z1234567890.a((0,1).b", "z1234567890", "a((0,1)", "b")]
[DataRow("1234567890z.a(0,1)).b", "1234567890z", "a(0,1))", "b")]
[DataRow("z.a1234567890(0,1)).b", "z", "a1234567890(0,1))", "b")]
[DataRow("z.1234567890a(0,1)).b", "z", "1234567890a(0,1))", "b")]
[DataRow("z.a(0.21).b1234567890", "z", "a(0.21)", "b1234567890")]
[DataRow("z.a(0.21).1234567890b", "z", "a(0.21)", "1234567890b")]

// These produce strange results but don't output errors.
// Will revisit these if users report errors.
Expand Down

0 comments on commit 10d5368

Please sign in to comment.