Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-re2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-re2
Commits
9b897f6b
Commit
9b897f6b
authored
Mar 28, 2016
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test the longest_match option
parent
86d6a633
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
1 deletion
+35
-1
options.vtc
src/tests/options.vtc
+35
-1
No files found.
src/tests/options.vtc
View file @
9b897f6b
# looks like -*- vcl -*-
varnishtest "
literal, never_nl, dot_nl, case_sensitive and one_line options
"
varnishtest "
options: literal never_nl dot_nl case_sensitive one_line longest_match
"
# Tests from re2 testing/parse_test.cc and testing/re2_test.cc
...
...
@@ -24,6 +24,8 @@ varnish v1 -vcl {
new case = re2.regex("(?i)([wand]{5})", case_sensitive=true);
new not_one = re2.regex("^a$", posix_syntax=true);
new one = re2.regex("^a$", posix_syntax=true, one_line=true);
new first = re2.regex("a(b|bb)");
new longest = re2.regex("a(b|bb)", longest_match=true);
}
sub vcl_recv {
...
...
@@ -88,6 +90,12 @@ a
a"} )) {
set resp.http.one = "match";
}
if (first.match("abb")) {
set resp.http.first = first.backref(0);
}
if (longest.match("abb")) {
set resp.http.longest = longest.backref(0);
}
}
} -start
...
...
@@ -110,6 +118,8 @@ client c1 {
expect resp.http.case1 == "Wanda"
expect resp.http.not_one == "match"
expect resp.http.one == <undef>
expect resp.http.first == "ab"
expect resp.http.longest == "abb"
} -run
# match() function
...
...
@@ -183,6 +193,12 @@ a
a"}, one_line=true)) {
set resp.http.one = "match";
}
if (re2.match("a(b|bb)", "abb")) {
set resp.http.first = re2.backref(0);
}
if (re2.match("a(b|bb)", "abb", longest_match=true)) {
set resp.http.longest = re2.backref(0);
}
}
}
...
...
@@ -301,6 +317,9 @@ a
a"} )) {
set resp.http.one = "match";
}
# No test for longest_match, because without backrefs
# we can't distinguish which of two alternatives were
# matched.
}
}
...
...
@@ -387,6 +406,9 @@ a"}, rewrite="\1z"), {"
re2.sub(pattern="^a$", posix_syntax=true, text={"a
a
a"}, rewrite="z", fallback="fail", one_line=true);
set resp.http.first = re2.sub("a(b|bb)", "abb", "z");
set resp.http.longest = re2.sub("a(b|bb)", "abb", "z",
longest_match=true);
}
}
...
...
@@ -406,6 +428,8 @@ client c2 {
expect resp.http.case == "A fish named *Arty*"
expect resp.http.not_one == "znana"
expect resp.http.one == "fail"
expect resp.http.first == "zb"
expect resp.http.longest == "z"
} -run
# suball() function
...
...
@@ -471,6 +495,9 @@ a"}, rewrite="\1z"), {"
re2.suball(pattern="^a$", posix_syntax=true, text={"a
a
a"}, rewrite="z", fallback="fail", one_line=true);
set resp.http.first = re2.suball("a(b|bb)", "abb", "z");
set resp.http.longest = re2.suball("a(b|bb)", "abb", "z",
longest_match=true);
}
}
...
...
@@ -489,6 +516,8 @@ client c3 {
expect resp.http.case == "A fish named *Arty*"
expect resp.http.not_one == "znznz"
expect resp.http.one == "fail"
expect resp.http.first == "zb"
expect resp.http.longest == "z"
} -run
# extract() function
...
...
@@ -550,6 +579,9 @@ a"}, rewrite="\1z");
re2.extract(pattern="^a$", posix_syntax=true, text={"a
a
a"}, rewrite="z", fallback="fail",one_line=true);
set resp.http.first = re2.extract("a(b|bb)", "abb", "\0:\1");
set resp.http.longest = re2.extract("a(b|bb)", "abb", "\0:\1",
longest_match=true);
}
}
...
...
@@ -568,4 +600,6 @@ client c3 {
expect resp.http.case == "Arty"
expect resp.http.not_one == "z"
expect resp.http.one == "fail"
expect resp.http.first == "ab:b"
expect resp.http.longest == "abb:bb"
} -run
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment