Commit 619bb94b authored by Geoff Simmons's avatar Geoff Simmons

add tests for character encodings with the set object interface

parent 2b39d946
......@@ -3,6 +3,9 @@
varnishtest "latin1 and utf8 encoding"
# Tests from re2 testing/re2_test.cc
# regex object and match function
varnish v1 -vcl {
import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so";
backend b { .host = "${bad_ip}"; }
......@@ -116,3 +119,73 @@ client c1 {
expect resp.http.patternbytesf == <undef>
expect resp.http.patterncharsf == "match"
} -run
# set object
varnish v1 -vcl {
import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new ninebytes = re2.set();
ninebytes.add("^.........$");
ninebytes.compile();
new threechars = re2.set(utf8=true);
threechars.add("^...$");
threechars.compile();
new bytes = re2.set();
bytes.add({"^日扼語$"});
bytes.compile();
new chars = re2.set(utf8=true);
chars.add({"^日扼語$"});
chars.compile();
new patternbytes = re2.set();
patternbytes.add({"^.扼.$"});
patternbytes.compile();
new patternchars = re2.set(utf8=true);
patternchars.add({"^.扼.$"});
patternchars.compile();
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
if (ninebytes.match({"日扼語"})) {
set resp.http.ninebytes = "match";
}
if (threechars.match({"日扼語"})) {
set resp.http.threechars = "match";
}
if (bytes.match({"日扼語"})) {
set resp.http.bytes = "match";
}
if (chars.match({"日扼語"})) {
set resp.http.chars = "match";
}
if (patternbytes.match({"日扼語"})) {
set resp.http.patternbytes = "match";
}
if (patternchars.match({"日扼語"})) {
set resp.http.patternchars = "match";
}
}
}
client c1 {
txreq
rxresp
expect resp.http.ninebytes == "match"
expect resp.http.threechars == "match"
expect resp.http.bytes == "match"
expect resp.http.chars == "match"
expect resp.http.patternbytes == <undef>
expect resp.http.patternchars == "match"
} -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