From ad7e1293a845ee39288ec4e72d03627ca4dda976 Mon Sep 17 00:00:00 2001 From: Keuvain Date: Sat, 12 May 2018 12:55:52 +0200 Subject: [PATCH] Update valid characters for alternative name Fix #51. --- src/Strinken/Core/Extensions.cs | 4 ++-- src/Strinken/Core/ParsingMethod.cs | 2 +- test/Strinken.Tests/EngineTests.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Strinken/Core/Extensions.cs b/src/Strinken/Core/Extensions.cs index a850a03..be19ae1 100644 --- a/src/Strinken/Core/Extensions.cs +++ b/src/Strinken/Core/Extensions.cs @@ -8,7 +8,7 @@ namespace Strinken.Core /// internal static class Extensions { - private static readonly List ValidAlternativeNameCharacter = new List { '*', '$', '?', '!', '&', '.', '#', '%' }; + private static readonly List ValidAlternativeNameCharacter = new List("!%&*+./<=>@^|~?$#".ToCharArray()); /// /// Tests if a is an invalid token name character i.e. not a-z, A-Z, 0-9, - or _. @@ -18,7 +18,7 @@ internal static class Extensions public static bool IsInvalidTokenNameCharacter(this char c) => !char.IsLetter(c) && c != '-' && c != '_'; /// - /// Tests if a is an invalid alternative name character i.e. not *, $, ?, !, & or .. + /// Tests if a is an invalid alternative name character i.e. not in "!%&*+./<=>@^|~?$#". /// /// The to test. /// A value indicating whether the is an invalid alternative name character diff --git a/src/Strinken/Core/ParsingMethod.cs b/src/Strinken/Core/ParsingMethod.cs index dbc8bf8..54fa461 100644 --- a/src/Strinken/Core/ParsingMethod.cs +++ b/src/Strinken/Core/ParsingMethod.cs @@ -11,7 +11,7 @@ internal enum ParsingMethod Name, /// - /// Parse string as a name (letter + '-' + '_') or as a symbol (*, $, ?, !, & or .). + /// Parse string as a name (letter + '-' + '_') or as a symbol (!%&*+./<=>@^|~?$#). /// NameOrSymbol, diff --git a/test/Strinken.Tests/EngineTests.cs b/test/Strinken.Tests/EngineTests.cs index 9a694fd..f9878e9 100644 --- a/test/Strinken.Tests/EngineTests.cs +++ b/test/Strinken.Tests/EngineTests.cs @@ -262,7 +262,7 @@ public void Run_ValidCharacterInString_DoesNotThrow(string input) [InlineData("{ipsum:filt*er}", '*', 11)] [InlineData("{ipsum:fi!}", '!', 9)] [InlineData("{ipsum:?f}", 'f', 8)] - [InlineData("{ipsum:!!^}", '^', 9)] + [InlineData("{ipsum:!!-}", '-', 9)] public void Run_InvalidCharacterInFilterName_ReturnsFalse(string input, char illegalChar, int position) { EngineResult result = StrinkenEngine.Run(input);