summaryrefslogtreecommitdiffabout
path: root/tests
authorSergey Poznyakoff <gray@gnu.org.ua>2017-08-01 08:22:27 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2017-08-01 08:36:20 (GMT)
commitd7399e572e334fb036c7f6b59400f5075147054c (patch) (side-by-side diff)
tree868c700aa625ab8d413a4191ec3c6cc61b72e5ad /tests
downloadvmod-dict-d7399e572e334fb036c7f6b59400f5075147054c.tar.gz
vmod-dict-d7399e572e334fb036c7f6b59400f5075147054c.tar.bz2
Initial commit
Diffstat (limited to 'tests') (more/less context) (ignore whitespace changes)
-rw-r--r--tests/.gitignore6
-rw-r--r--tests/Makefile.am71
-rw-r--r--tests/atlocal.in7
-rw-r--r--tests/ci.at77
-rw-r--r--tests/cs.at77
-rw-r--r--tests/num.dict12
-rw-r--r--tests/testsuite.at21
7 files changed, 271 insertions, 0 deletions
diff --git a/tests/.gitignore b/tests/.gitignore
new file mode 100644
index 0000000..93f8f46
--- a/dev/null
+++ b/tests/.gitignore
@@ -0,0 +1,6 @@
+atconfig
+atlocal
+package.m4
+testsuite
+testsuite.dir
+testsuite.log
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..d70517f
--- a/dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,71 @@
+# This file is part of vmod_dict.
+# Copyright (C) 2017 Sergey Poznyakoff
+#
+# Vmod_dict is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# Vmod_dict is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with vmod_dict. If not, see <http://www.gnu.org/licenses/>.
+
+EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 num.dict
+DISTCLEANFILES = atconfig $(check_SCRIPTS)
+MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE)
+CLEANFILES = .TESTINIT FAILURE
+
+## ------------ ##
+## package.m4. ##
+## ------------ ##
+
+$(srcdir)/package.m4: $(top_srcdir)/configure.ac
+ $(AM_V_GEN){ \
+ echo '# Signature of the current package.'; \
+ echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])'; \
+ echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])'; \
+ echo 'm4_define([AT_PACKAGE_VERSION], [@PACKAGE_VERSION@])'; \
+ echo 'm4_define([AT_PACKAGE_STRING], [@PACKAGE_STRING@])'; \
+ echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \
+ } >$(srcdir)/package.m4
+
+#
+
+## ------------ ##
+## Test suite. ##
+## ------------ ##
+
+TESTSUITE_AT = \
+ testsuite.at\
+ ci.at\
+ cs.at
+
+TESTSUITE = $(srcdir)/testsuite
+M4=m4
+
+AUTOTEST = $(AUTOM4TE) --language=autotest
+$(TESTSUITE): package.m4 $(TESTSUITE_AT)
+ $(AM_V_GEN)$(AUTOTEST) -I $(srcdir) testsuite.at -o $@.tmp
+ $(AM_V_at)mv $@.tmp $@
+
+atconfig: $(top_builddir)/config.status
+ @cd $(top_builddir) && ./config.status tests/$@
+
+clean-local:
+ @test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean
+
+check-local: atconfig atlocal $(TESTSUITE)
+ @$(SHELL) $(TESTSUITE)
+
+# Run the test suite on the *installed* tree.
+#installcheck-local:
+# $(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin
+
+
+
+
+
diff --git a/tests/atlocal.in b/tests/atlocal.in
new file mode 100644
index 0000000..142b9ed
--- a/dev/null
+++ b/tests/atlocal.in
@@ -0,0 +1,7 @@
+# @configure_input@ -*- shell-script -*-
+# Configurable variable values for vmod_dict test suite.
+# Copyright (C) 2017 Sergey Poznyakoff
+
+PATH=@abs_builddir@:@abs_top_builddir@/src:@abs_top_srcdir@/build-aux:$top_srcdir:$srcdir:$PATH
+VARNISHTEST=@VARNISHTEST@
+VARNISHD=@VARNISHD@
diff --git a/tests/ci.at b/tests/ci.at
new file mode 100644
index 0000000..6554e53
--- a/dev/null
+++ b/tests/ci.at
@@ -0,0 +1,77 @@
+AT_SETUP([case-insensitive])
+AT_KEYWORDS([case-insensitive])
+AT_VARNISHTEST([dict],[
+ sub vcl_init {
+ dict.load("\${vmod_topsrc}/tests/num.dict", true, 0);
+ }
+ sub vcl_recv {
+ set req.http.X-result = dict.lookup(regsub(req.url, "^/(.*)", "\1"));
+ return (hash);
+ }
+ sub vcl_deliver {
+ set resp.http.X-result = req.http.X-result;
+ }
+],
+[ txreq -url "/oNe"
+ rxresp
+ expect resp.http.X-result == "en"
+ txreq -url "/TWO"
+ rxresp
+ expect resp.http.X-result == "to"
+ txreq -url "/THREE"
+ rxresp
+ expect resp.http.X-result == "tre"
+ txreq -url "/FOUR"
+ rxresp
+ expect resp.http.X-result == "fire"
+ txreq -url "/FIVE"
+ rxresp
+ expect resp.http.X-result == "fem"
+ txreq -url "/SIX"
+ rxresp
+ expect resp.http.X-result == "seks"
+ txreq -url "/SEVEN"
+ rxresp
+ expect resp.http.X-result == "sju"
+ txreq -url "/EIGHT"
+ rxresp
+ expect resp.http.X-result == "aatte"
+ txreq -url "/nINe"
+ rxresp
+ expect resp.http.X-result == "ni"
+ txreq -url "/Ten"
+ rxresp
+ expect resp.http.X-result == "ti"
+ txreq -url "/ELeVEN"
+ rxresp
+ expect resp.http.X-result == "elleve"
+ txreq -url "/twELve"
+ rxresp
+ expect resp.http.X-result == "tolv"
+],
+[ rxreq
+ txresp
+ rxreq
+ txresp
+ rxreq
+ txresp
+ rxreq
+ txresp
+ rxreq
+ txresp
+ rxreq
+ txresp
+ rxreq
+ txresp
+ rxreq
+ txresp
+ rxreq
+ txresp
+ rxreq
+ txresp
+ rxreq
+ txresp
+ rxreq
+ txresp
+])
+AT_CLEANUP
diff --git a/tests/cs.at b/tests/cs.at
new file mode 100644
index 0000000..f847773
--- a/dev/null
+++ b/tests/cs.at
@@ -0,0 +1,77 @@
+AT_SETUP([case-sensitive])
+AT_KEYWORDS([case-sensitive])
+AT_VARNISHTEST([dict],[
+ sub vcl_init {
+ dict.load("\${vmod_topsrc}/tests/num.dict", false, 0);
+ }
+ sub vcl_recv {
+ set req.http.X-result = dict.lookup(regsub(req.url, "^/(.*)", "\1"));
+ return (hash);
+ }
+ sub vcl_deliver {
+ set resp.http.X-result = req.http.X-result;
+ }
+],
+[ txreq -url "/one"
+ rxresp
+ expect resp.http.X-result == "en"
+ txreq -url "/two"
+ rxresp
+ expect resp.http.X-result == "to"
+ txreq -url "/three"
+ rxresp
+ expect resp.http.X-result == "tre"
+ txreq -url "/four"
+ rxresp
+ expect resp.http.X-result == "fire"
+ txreq -url "/five"
+ rxresp
+ expect resp.http.X-result == "fem"
+ txreq -url "/six"
+ rxresp
+ expect resp.http.X-result == "seks"
+ txreq -url "/seven"
+ rxresp
+ expect resp.http.X-result == "sju"
+ txreq -url "/eight"
+ rxresp
+ expect resp.http.X-result == "aatte"
+ txreq -url "/nine"
+ rxresp
+ expect resp.http.X-result == "ni"
+ txreq -url "/ten"
+ rxresp
+ expect resp.http.X-result == "ti"
+ txreq -url "/eleven"
+ rxresp
+ expect resp.http.X-result == "elleve"
+ txreq -url "/twelve"
+ rxresp
+ expect resp.http.X-result == "tolv"
+],
+[ rxreq
+ txresp
+ rxreq
+ txresp
+ rxreq
+ txresp
+ rxreq
+ txresp
+ rxreq
+ txresp
+ rxreq
+ txresp
+ rxreq
+ txresp
+ rxreq
+ txresp
+ rxreq
+ txresp
+ rxreq
+ txresp
+ rxreq
+ txresp
+ rxreq
+ txresp
+])
+AT_CLEANUP
diff --git a/tests/num.dict b/tests/num.dict
new file mode 100644
index 0000000..c199908
--- a/dev/null
+++ b/tests/num.dict
@@ -0,0 +1,12 @@
+one en
+two to
+three tre
+four fire
+five fem
+six seks
+seven sju
+eight aatte
+nine ni
+ten ti
+eleven elleve
+twelve tolv
diff --git a/tests/testsuite.at b/tests/testsuite.at
new file mode 100644
index 0000000..be04b56
--- a/dev/null
+++ b/tests/testsuite.at
@@ -0,0 +1,21 @@
+# This file is part of vmod_dict.
+# Copyright (C) 2017 Sergey Poznyakoff
+#
+# Vmod_dict is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# Vmod_dict is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with vmod_dict. If not, see <http://www.gnu.org/licenses/>.
+
+m4_include([../acvmod/testsuite.inc])
+AT_INIT
+m4_include([cs.at])
+m4_include([ci.at])
+

Return to:

Send suggestions and report system problems to the System administrator.