diff options
author | deva <deva> | 2011-07-01 11:34:38 +0000 |
---|---|---|
committer | deva <deva> | 2011-07-01 11:34:38 +0000 |
commit | 112b2b7bde8d215d1e62b91320c01e8aa2309cac (patch) | |
tree | 21073a50d97759fc5df60e43aadb847ced2a70e1 /server/src | |
parent | 42e43b044ffc49e3128ae59e75ce5ffd84c371be (diff) |
More tests.
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/luaquerymapper.cc | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/server/src/luaquerymapper.cc b/server/src/luaquerymapper.cc index f593c28..56b7c1b 100644 --- a/server/src/luaquerymapper.cc +++ b/server/src/luaquerymapper.cc @@ -228,6 +228,8 @@ TEST_BEGIN; time_t now = time(NULL); { + LUAQueryMapper mapper; + QueryResult res; res.groups["test"].timestamp = now; res.groups["test"].source = "test app"; @@ -240,9 +242,18 @@ time_t now = time(NULL); res.groups["test"].groups["subtest"].groups["subsubtest"].timestamp = now + 2; res.groups["test"].groups["subtest"].groups["subsubtest"].values["somevalue"] = "hello world!!"; - LUAQueryMapper mapper; mapper.addQueryResult(res); + QueryResult res2; + res2.groups["test"].groups["subtest"].source = "src"; + res2.groups["test"].groups["subtest"].timestamp = now + 3; + res2.groups["test"].groups["subtest"].values["val"] = "gnaf"; + res2.groups["test"].groups["subgrp"].source = "src2"; + res2.groups["test"].groups["subgrp"].timestamp = now + 4; + res2.groups["test"].groups["subgrp"].values["val2"] = "gnaf2"; + + mapper.addQueryResult(res2); + // Test simple value forwarding with nesting std::string luamap = "return test.subtest.subsubtest.somevalue.value, test.subtest.subsubtest.somevalue.timestamp, test.subtest.subsubtest.somevalue.source"; @@ -275,6 +286,22 @@ time_t now = time(NULL); TEST_EQUAL_STR(value.value, "3.14", "Test value"); TEST_EQUAL_INT(value.timestamp, now, "Test timestamp"); TEST_EQUAL_STR(value.source, "test app", "Test source"); + + luamap = "return test.subtest.val.value, test.subtest.val.timestamp, test.subtest.val.source"; + + value = mapper.map(luamap); + + TEST_EQUAL_STR(value.value, "gnaf", "Test value"); + TEST_EQUAL_INT(value.timestamp, now + 3, "Test timestamp"); + TEST_EQUAL_STR(value.source, "src", "Test source"); + + luamap = "return test.subgrp.val2.value, test.subgrp.val2.timestamp, test.subgrp.val2.source"; + + value = mapper.map(luamap); + + TEST_EQUAL_STR(value.value, "gnaf2", "Test value"); + TEST_EQUAL_INT(value.timestamp, now + 4, "Test timestamp"); + TEST_EQUAL_STR(value.source, "src2", "Test source"); } QueryResult res; |