mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-26 14:21:49 +00:00
ZoneCodeGenerator: Add tests for Matchers to test TokenOffset and Tag behaviour
This commit is contained in:
@ -41,5 +41,45 @@ namespace ZoneCodeGeneratorTests.Parsing.Matching.Matchers
|
||||
Assert.IsTrue(result.Successful);
|
||||
Assert.AreEqual(0, result.ConsumedTokenCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void EnsureMakesCorrectUseOfTokenOffset()
|
||||
{
|
||||
var testMatcher = new TestMatcher(true, 1);
|
||||
var groupOptional = new MatcherGroupOptional(testMatcher);
|
||||
|
||||
var result = groupOptional.Test(matchingContext, 7);
|
||||
|
||||
Assert.IsTrue(result.Successful);
|
||||
|
||||
Assert.AreEqual(7, testMatcher.TestTokenOffset);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void EnsureAddsTagWhenMatched()
|
||||
{
|
||||
var testMatcher = new TestMatcher(true, 1).WithTag("testTag");
|
||||
var groupOptional = new MatcherGroupOptional(testMatcher).WithTag("optionalTag");
|
||||
|
||||
var result = groupOptional.Test(matchingContext, 0);
|
||||
|
||||
Assert.IsTrue(result.Successful);
|
||||
Assert.AreEqual(2, result.MatchedTags.Count);
|
||||
Assert.AreEqual("optionalTag", result.MatchedTags[0]);
|
||||
Assert.AreEqual("testTag", result.MatchedTags[1]);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void EnsureDoesStillAddItsOwnTagWhenMatcherDoesNotMatch()
|
||||
{
|
||||
var testMatcher = new TestMatcher(false, 0).WithTag("testTag");
|
||||
var groupOptional = new MatcherGroupOptional(testMatcher).WithTag("optionalTag");
|
||||
|
||||
var result = groupOptional.Test(matchingContext, 0);
|
||||
|
||||
Assert.IsTrue(result.Successful);
|
||||
Assert.AreEqual(1, result.MatchedTags.Count);
|
||||
Assert.AreEqual("optionalTag", result.MatchedTags[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user