public void Captures() { // Arrange var data = Json.String("this is the test string"); var op = new FunctionCall( RegexMatch.Builtin, new Literal("(t)(h)"), new Literal { Value = Json.Null }, new Literal { Value = Json.False }); // Act var result = op.RunAsScalar(data); // Assert var expectedJson = @" [{ ""offset"": 0, ""length"": 2, ""string"": ""th"", ""captures"": [ { ""offset"": 0, ""length"": 1, ""string"": ""t"", ""name"": ""1"" }, { ""offset"": 1, ""length"": 1, ""string"": ""h"", ""name"": ""2"" } ] }]"; result.DeepEqual(expectedJson.AsJson()).Should().BeTrue(); }
public void JustTest() { // Arrange var data = Json.String("this is the test string"); var op = new FunctionCall( RegexMatch.Builtin, new Literal("th"), new Literal { Value = Json.Null }, new Literal { Value = Json.True }); // Act var result = op.RunAsScalar(data); // Assert result.DeepEqual("true".AsJson()).Should().BeTrue(); }
public void MultiLine() { // Arrange var data = Json.String("TH\nis"); var op = new FunctionCall( RegexMatch.Builtin, new Literal("h.i"), new Literal("im"), new Literal { Value = Json.False }); // Act var result = op.RunAsScalar(data); // Assert var expectedJson = "[{\"offset\":1,\"length\":3,\"string\":\"H\\ni\",\"captures\":[]}]"; result.DeepEqual(expectedJson.AsJson()).Should().BeTrue(); }
public void IgnoreWhiteSpace() { // Arrange var data = Json.String("this"); var op = new FunctionCall( RegexMatch.Builtin, new Literal("th is"), new Literal("x"), new Literal { Value = Json.False }); // Act var result = op.RunAsScalar(data); // Assert var expectedJson = "[{\"offset\":0,\"length\":4,\"string\":\"this\",\"captures\":[]}]"; result.DeepEqual(expectedJson.AsJson()).Should().BeTrue(); }
public void CaseInsensitive() { // Arrange var data = Json.String("THis"); var op = new FunctionCall( RegexMatch.Builtin, new Literal("th"), new Literal("i"), new Literal { Value = Json.False }); // Act var result = op.RunAsScalar(data); // Assert var expectedJson = @" [{""offset"":0,""length"":2,""string"":""TH"",""captures"":[]}]"; result.DeepEqual(expectedJson.AsJson()).Should().BeTrue(); }