From: Yoshitaka Aharen Date: Fri, 12 Oct 2012 05:21:15 +0000 (+0900) Subject: [2155] update test case according to the review comment X-Git-Tag: trac2487_base~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c638fb4e2776b24b7ecf3c071086056d5cc9d78f;p=thirdparty%2Fkea.git [2155] update test case according to the review comment --- diff --git a/src/bin/auth/tests/auth_srv_unittest.cc b/src/bin/auth/tests/auth_srv_unittest.cc index cbd29b6877..2d5e688494 100644 --- a/src/bin/auth/tests/auth_srv_unittest.cc +++ b/src/bin/auth/tests/auth_srv_unittest.cc @@ -131,19 +131,8 @@ protected: // Checks whether all Rcode counters are set to zero void checkAllRcodeCountersZero() const { - const std::map - stats_map(server.getStatistics()->mapValue()); - - const std::string rcode_prefix("rcode."); - for (std::map::const_iterator - i = stats_map.begin(), e = stats_map.end(); - i != e; - ++i) - { - if (i->first.compare(0, rcode_prefix.size(), rcode_prefix) == 0) { - checkRcodeCounter(i->first, i->second->intValue(), 0); - } - } + // with checking NOERROR == 0 and the others are 0 + checkAllRcodeCountersZeroExcept(Rcode::NOERROR(), 0); } // Checks whether all Rcode counters are set to zero except the given @@ -248,15 +237,24 @@ createBuiltinVersionResponse(const qid_t qid, vector& data) { renderer.getLength()); } +// Check if the item has expected value. +// Before reading the item, check the item exists. void expectCounterItem(ConstElementPtr stats, const std::string& item, const int expected) { ConstElementPtr value(Element::create(0)); if (item == "queries.udp" || item == "queries.tcp" || expected != 0) { + // if the value of the item is not zero, the item exists and has + // expected value + // item "queries.udp" and "queries.tcp" exists whether the value + // is zero or nonzero ASSERT_TRUE(stats->find(item, value)) << " Item: " << item; + // Get the value of the item with another method because of API bug + // (ticket #2302) value = stats->find(item); EXPECT_EQ(expected, value->intValue()) << " Item: " << item; } else { + // otherwise the item does not exist ASSERT_FALSE(stats->find(item, value)) << " Item: " << item << std::endl << " Value: " << value->intValue(); }