Commit 6271111b authored by Geoff Simmons's avatar Geoff Simmons

add tests for the sub() method to vcl_regex.vtc

parent 67216fc2
# looks like -*- vcl -*-
varnishtest "re2.backref not affected by standard VCL regex code"
varnishtest "backrefs not affected by standard VCL regex code"
varnish v1 -vcl+backend {
import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so";
......@@ -23,6 +23,8 @@ varnish v1 -vcl+backend {
if (resp.http.foo ~ "bar(baz)") {
set resp.http.tilde0 = barbaz.backref(0, "tilde0");
set resp.http.tilde1 = barbaz.backref(1, "tilde1");
set resp.http.tildesub =
barbaz.sub(resp.http.foo, "\0\1", "tildesub");
} else {
set resp.status = 999;
}
......@@ -30,6 +32,8 @@ varnish v1 -vcl+backend {
if (resp.http.foo !~ "bar(quux)") {
set resp.http.neg0 = barbaz.backref(0, "neg0");
set resp.http.neg1 = barbaz.backref(1, "neg1");
set resp.http.negsub =
barbaz.sub(resp.http.foo, "\0\1", "negsub");
} else {
set resp.status = 999;
}
......@@ -38,11 +42,15 @@ varnish v1 -vcl+backend {
= regsub(resp.http.foo, "bar(baz)", "\1");
set resp.http.regsub0 = barbaz.backref(0, "regsub0");
set resp.http.regsub1 = barbaz.backref(1, "regsub1");
set resp.http.regsubsub = barbaz.sub(resp.http.foo, "\0\1",
"regsubsub");
set resp.http.regsuball
= regsuball(resp.http.foo, "(.)", "x");
set resp.http.regsuball0 = barbaz.backref(0, "regsuball0");
set resp.http.regsuball1 = barbaz.backref(1, "regsuball1");
set resp.http.regsuballsub = barbaz.sub(resp.http.foo, "\0\1",
"regsuballsub");
}
} -start
......@@ -53,14 +61,18 @@ client c1 {
expect resp.status == 200
expect resp.http.tilde0 == "barbaz"
expect resp.http.tilde1 == "bar"
expect resp.http.tildesub == "barbazbar"
expect resp.http.neg0 == "barbaz"
expect resp.http.neg1 == "bar"
expect resp.http.negsub == "barbazbar"
expect resp.http.regsub == "baz"
expect resp.http.regsub0 == "barbaz"
expect resp.http.regsub1 == "bar"
expect resp.http.regsubsub == "barbazbar"
expect resp.http.regsuball == "xxxxxx"
expect resp.http.regsuball0 == "barbaz"
expect resp.http.regsuball1 == "bar"
expect resp.http.regsuballsub == "barbazbar"
} -run
# Function interface
......@@ -106,4 +118,18 @@ varnish v1 -vcl+backend {
}
client c1 -run
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.http.tilde0 == "barbaz"
expect resp.http.tilde1 == "bar"
expect resp.http.neg0 == "barbaz"
expect resp.http.neg1 == "bar"
expect resp.http.regsub == "baz"
expect resp.http.regsub0 == "barbaz"
expect resp.http.regsub1 == "bar"
expect resp.http.regsuball == "xxxxxx"
expect resp.http.regsuball0 == "barbaz"
expect resp.http.regsuball1 == "bar"
} -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