diff options
author | deva <deva> | 2011-02-14 14:09:04 +0000 |
---|---|---|
committer | deva <deva> | 2011-02-14 14:09:04 +0000 |
commit | 04f275fea9186a75836b589022a9fa410aea7b02 (patch) | |
tree | 70d5e61af8e2e8319326d3ca8a9f3ea805fe06e8 /server/src/widgetvalue.cc | |
parent | 95cfffa53760942c3ccf6abc18b81f48d03a3ff6 (diff) |
Added gcov (coverage measurement) in unittests.
Diffstat (limited to 'server/src/widgetvalue.cc')
-rw-r--r-- | server/src/widgetvalue.cc | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/server/src/widgetvalue.cc b/server/src/widgetvalue.cc index 053eecc..3b68e8e 100644 --- a/server/src/widgetvalue.cc +++ b/server/src/widgetvalue.cc @@ -40,8 +40,10 @@ static bool getMapValue(Value &value, maps_t::iterator li = maps.begin(); while(li != maps.end()) { Map &_map = *li; - if(_map.attributes["name"] == map) { - luamap = _map.attributes["lua"]; + if(_map.attributes.find("name") != _map.attributes.end() && + _map.attributes["name"] == map) { + if(_map.attributes.find("lua") != _map.attributes.end()) + luamap = _map.attributes["lua"]; } li++; } @@ -145,8 +147,7 @@ bool getValue(Value &value, TEST_BEGIN; -pracro_debug_init(); -pracro_debug_parse("+all"); +debug_parse("+all"); time_t now = time(NULL); @@ -349,6 +350,39 @@ time_t now = time(NULL); TEST_EQUAL_STR(value.source, v.source, "Got the right source?"); } +{ + Conf::db_max_ttl = 1000; + Conf::pentominos_max_ttl = 500; + + Value value; + + attr_t attr; + attr["name"] = "foo"; + attr["value"] = "hello"; + attr["map"] = "bar"; + + maps_t maps; + Map m; + char tbuf[32]; sprintf(tbuf, "%ld", now - 1); + std::string val = "le valu"; + m.attributes["name"] = "bar"; + m.attributes["lua"] = "return '"+val+"', "+tbuf+", 'artefact'"; + maps.push_back(m); + LUAQueryMapper mapper; + + Values values; + Value v; + v.value = "world"; + v.source = "pracro"; + v.timestamp = now ; + values["foo"] = v; + + TEST_TRUE(getValue(value, attr, maps, mapper, values), "Got value?"); + TEST_EQUAL_STR(value.value, v.value, "Got the right value?"); + TEST_EQUAL_INT(value.timestamp, v.timestamp, "Got the right timestamp?"); + TEST_EQUAL_STR(value.source, v.source, "Got the right source?"); +} + TEST_END; #endif/*TEST_WIDGETVALUE*/ |