-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
…nction as per Issue #2
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace MagicExpression.Test | ||
{ | ||
[TestClass] | ||
public class GithubIssuesTests | ||
{ | ||
/// <summary> | ||
/// Test showing the use of Character(Characters.Numerals) | ||
/// </summary> | ||
[TestMethod] | ||
public void TestIssue2_CharacterEnumWithoutCharacterIn() | ||
{ | ||
var ipAdress = Magex.New().Alternative( | ||
Magex.New() | ||
.Character('2') | ||
.CharacterIn('0', '-', '4') | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Timothep
Author
Collaborator
|
||
.Character(Characters.Numeral), | ||
This comment has been minimized.
Sorry, something went wrong.
ghusse
Owner
|
||
Magex.New() | ||
.String("25") | ||
.CharacterIn('0', '-', '5'), | ||
Magex.New() | ||
.CharacterIn('0', '1').Repeat.AtMostOnce() | ||
.Character(Characters.Numeral) | ||
.Character(Characters.Numeral).Repeat.AtMostOnce()); | ||
|
||
var expression = Magex.New().CaptureAs("First", ipAdress) | ||
.Character('.') | ||
.CaptureAs("Second", ipAdress) | ||
.Character('.') | ||
.CaptureAs("Third", ipAdress) | ||
.Character('.') | ||
.CaptureAs("Fourth", ipAdress); | ||
|
||
Assert.AreEqual( | ||
@"(?<First>(?:2[0-4]\\d|25[0-5]|[01]?\\d\\d?))\.(?<Second>(?:2[0-4]\\d|25[0-5]|[01]?\\d\\d?))\.(?<Third>(?:2[0-4]\\d|25[0-5]|[01]?\\d\\d?))\.(?<Fourth>(?:2[0-4]\\d|25[0-5]|[01]?\\d\\d?))" | ||
, expression.Expression, expression.Expression); | ||
} | ||
|
||
} | ||
} |
Not fan of this syntax, because you have to know regexp syntax to use it: not very self-explanatory. We probably need to add a way to do this without needing to bend the model like that.