Commit 1fd0f08b authored by Geoff Simmons's avatar Geoff Simmons

add tests for the sub() method and function when the match fails

parent dc54c3fb
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
varnishtest "sub() method and function" varnishtest "sub() method and function"
# Tests from re2 testing/re2_test.cc
varnish v1 -vcl { varnish v1 -vcl {
import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so"; import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so";
backend be { .host = "${bad_ip}"; } backend be { .host = "${bad_ip}"; }
...@@ -22,6 +21,7 @@ varnish v1 -vcl { ...@@ -22,6 +21,7 @@ varnish v1 -vcl {
} }
sub vcl_synth { sub vcl_synth {
# Tests from re2 testing/re2_test.cc
set resp.http.pangram set resp.http.pangram
= piglatin.sub("the quick brown fox jumps over the lazy dogs.", = piglatin.sub("the quick brown fox jumps over the lazy dogs.",
"\2\1ay"); "\2\1ay");
...@@ -50,6 +50,10 @@ varnish v1 -vcl { ...@@ -50,6 +50,10 @@ varnish v1 -vcl {
set resp.http.bplusf = re2.sub("b+", "bbbbbb", "bb"); set resp.http.bplusf = re2.sub("b+", "bbbbbb", "bb");
set resp.http.bstar1f = re2.sub("b*", "bbbbbb", "bb"); set resp.http.bstar1f = re2.sub("b*", "bbbbbb", "bb");
set resp.http.bstar2f = re2.sub("b*", "aaaaa", "bb"); set resp.http.bstar2f = re2.sub("b*", "aaaaa", "bb");
# Match failure
set resp.http.bfail = b.sub("acd", "x", "fallbackb");
set resp.http.bfailf = re2.sub("b", "acd", "x", "fallbackf");
} }
} -start } -start
...@@ -78,4 +82,7 @@ client c1 { ...@@ -78,4 +82,7 @@ client c1 {
expect resp.http.bplusf == "bb" expect resp.http.bplusf == "bb"
expect resp.http.bstar1f == "bb" expect resp.http.bstar1f == "bb"
expect resp.http.bstar2f == "bbaaaaa" expect resp.http.bstar2f == "bbaaaaa"
expect resp.http.bfail == "fallbackb"
expect resp.http.bfailf == "fallbackf"
} -run } -run
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment