diff options
author | deva <deva> | 2008-05-15 14:19:02 +0000 |
---|---|---|
committer | deva <deva> | 2008-05-15 14:19:02 +0000 |
commit | 63d7e433f104dd13d015df3a048697fad6d43a55 (patch) | |
tree | 4dedec10891f4e9866ba5b3f9bfcd136cc0c7e16 /server/src/luaquerymapper.cc | |
parent | dd744c562f2f755a9fcd9ee5341c8c8702a9ee32 (diff) |
Added a lot of testcode... and fixed a lot of minor error (-Wall -Werror)
Diffstat (limited to 'server/src/luaquerymapper.cc')
-rw-r--r-- | server/src/luaquerymapper.cc | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/server/src/luaquerymapper.cc b/server/src/luaquerymapper.cc index f4f6f20..be18742 100644 --- a/server/src/luaquerymapper.cc +++ b/server/src/luaquerymapper.cc @@ -105,28 +105,33 @@ std::string LUAQueryMapper::map(const std::string &mapper) #ifdef TEST_LUAQUERYMAPPER +#include "queryhandler.h" +#include "queryparser.h" + int main() { - QueryResult res; + TCPSocket s; + s.connect("localhost", 11108); + + QueryHandler qh(&s, "2003791613"); - QueryResult group1; - group1.values["dims"] = "42"; + Query q1("lensmeter", "lensmeter"); + qh.addQuery(q1); - QueryResult group2; - group2.values["foo"] = "bar"; - group2.values["bar"] = "foo"; - group2.groups["fnuller"] = group1; + std::string res = qh.exec(); + + printf("%s\n", res.c_str()); - res.values["dims"] = "42"; - res.groups["dimmer"] = group2; + QueryParser e(res); + e.parse(); - LUAQueryMapper mapper(res); + LUAQueryMapper mapper(e.result); - std::string luamap = "return dimmer.fnuller.dims * 2 + dims"; - printf("%s\n", mapper.map(luamap).c_str()); + std::string luamap = "return right.sphere"; + printf("%s : %s\n", luamap.c_str(), mapper.map(luamap).c_str()); - luamap = "return math.sin(dimmer.fnuller.dims * 2 + dims)"; - printf("%s\n", mapper.map(luamap).c_str()); + luamap = "return math.sin(right.cyl) * 2"; + printf("%s : %s\n", luamap.c_str(), mapper.map(luamap).c_str()); return 0; } |