Commit 4a995c65 authored by Geoff Simmons's avatar Geoff Simmons

add a test for the utf8 option

parent 4c0baa24
# looks like -*- vcl -*-
varnishtest "latin1 and utf8 encoding"
# Tests from re2 testing/re2_test.cc
varnish v1 -vcl {
import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new ninebytes = re2.regex("^.........$");
new threechars = re2.regex("^...$", utf8=true);
new capture_one_byte = re2.regex("(.)");
new capture_one_char = re2.regex("(.)", utf8=true);
new bytes = re2.regex({"^日扼語$"});
new chars = re2.regex({"^日扼語$"}, utf8=true);
new patternbytes = re2.regex({"^.扼.$"});
new patternchars = re2.regex({"^.扼.$"}, utf8=true);
}
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 (capture_one_byte.match({"日扼語"})) {
if (capture_one_byte.backref(1) == {""}) {
set resp.http.captured_one_byte = "true";
}
}
if (capture_one_char.match({"日扼語"})) {
if (capture_one_char.backref(1) == {"日"}) {
set resp.http.captured_one_char = "true";
}
}
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";
}
}
} -start
client c1 {
txreq
rxresp
expect resp.http.ninebytes == "match"
expect resp.http.threechars == "match"
expect resp.http.captured_one_byte == "true"
expect resp.http.captured_one_char == "true"
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