Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        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();
        }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
        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();
        }