From 1666fa0e0d7a2297bc31eb366cce40465af005d8 Mon Sep 17 00:00:00 2001 From: cxl Date: Mon, 14 Apr 2014 18:14:40 +0000 Subject: [PATCH] .autotest git-svn-id: svn://ultimatepp.org/upp/trunk@7255 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- autotest/Witz/Witz.upp | 1 + autotest/Witz/main.cpp | 16 ++++++++++++++++ autotest/Witz/test2.witz | 1 + 3 files changed, 18 insertions(+) create mode 100644 autotest/Witz/test2.witz diff --git a/autotest/Witz/Witz.upp b/autotest/Witz/Witz.upp index db52e13f0..8e155da6d 100644 --- a/autotest/Witz/Witz.upp +++ b/autotest/Witz/Witz.upp @@ -5,6 +5,7 @@ uses Skylark; file + test2.witz, index.witz, etalon, main.cpp; diff --git a/autotest/Witz/main.cpp b/autotest/Witz/main.cpp index e7b53e570..03ae81244 100644 --- a/autotest/Witz/main.cpp +++ b/autotest/Witz/main.cpp @@ -30,6 +30,14 @@ struct MyApp : SkylarkApp { } }; +Value WitzUrlEncode(const Vector& arg, const Renderer *) { + return arg.GetCount() == 1 && IsString(arg[0]) ? UrlEncode(arg[0]) : String(); +} + +INITBLOCK { + Compiler::Register("url_encode", WitzUrlEncode); +} + CONSOLE_APP_MAIN { StdLogSetup(LOG_FILE|LOG_COUT); @@ -61,5 +69,13 @@ CONSOLE_APP_MAIN LOG("------------"); // SaveFile(GetDataFile("etalon"), result); ASSERT(result == LoadFile(GetDataFile("etalon"))); + + m.Add("name", "What is that?"); + http("res", m); + + result = http.RenderString("Witz/test2.witz"); + ASSERT(result == "What+is+that%3F\r\n"); + LOG(result); + LOG("========== OK"); } diff --git a/autotest/Witz/test2.witz b/autotest/Witz/test2.witz new file mode 100644 index 000000000..bbba029d1 --- /dev/null +++ b/autotest/Witz/test2.witz @@ -0,0 +1 @@ +$url_encode(res.name) \ No newline at end of file