BIND 10 trac2986test, updated. 07f200d6f400a7f8011386ed628652ed94b51bc1 [2986test] Added automatic conversion between intElement and uint64Element unsigned long long int is changed as uint64_t
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Jun 18 09:36:50 UTC 2013
The branch, trac2986test has been updated
via 07f200d6f400a7f8011386ed628652ed94b51bc1 (commit)
from 50bd7f26db18969b1fd5d315c5efb3ed6db86664 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 07f200d6f400a7f8011386ed628652ed94b51bc1
Author: Kazunori Fujiwara <fujiwara at wide.ad.jp>
Date: Tue Jun 18 18:35:13 2013 +0900
[2986test] Added automatic conversion between intElement and uint64Element
unsigned long long int is changed as uint64_t
-----------------------------------------------------------------------
Summary of changes:
src/bin/auth/tests/auth_srv_unittest.cc | 48 +++++++++++++++----------------
src/bin/auth/tests/statistics_util.cc | 11 +++----
src/bin/auth/tests/statistics_util.h | 2 +-
src/lib/cc/data.h | 15 ++++++++++
4 files changed, 46 insertions(+), 30 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/auth/tests/auth_srv_unittest.cc b/src/bin/auth/tests/auth_srv_unittest.cc
index 75be2e6..e24b341 100644
--- a/src/bin/auth/tests/auth_srv_unittest.cc
+++ b/src/bin/auth/tests/auth_srv_unittest.cc
@@ -142,7 +142,7 @@ protected:
// Checks whether all Rcode counters are set to zero except the given
// rcode (it is checked to be set to 'value')
- void checkAllRcodeCountersZeroExcept(const Rcode& rcode, unsigned long long value) const {
+ void checkAllRcodeCountersZeroExcept(const Rcode& rcode, uint64_t value) const {
std::string target_rcode_name = rcode.toText();
std::transform(target_rcode_name.begin(), target_rcode_name.end(),
target_rcode_name.begin(), ::tolower);
@@ -197,7 +197,7 @@ protected:
// Check if the counters exist and are initialized to 0.
void
checkCountersAreInitialized() {
- const std::map<std::string, unsigned long long int> expect;
+ const std::map<std::string, uint64_t> expect;
ConstElementPtr stats = server.getStatistics()->
get("zones")->get("_SERVER_");
checkStatisticsCounters(stats, expect);
@@ -314,7 +314,7 @@ TEST_F(AuthSrvTest, noClientList) {
ConstElementPtr stats_after = server.getStatistics()->get("zones")->
get("_SERVER_");
- std::map<std::string, unsigned long long int> expect;
+ std::map<std::string, uint64_t> expect;
expect["request.v4"] = 1;
expect["request.udp"] = 1;
expect["opcode.query"] = 1;
@@ -345,7 +345,7 @@ TEST_F(AuthSrvTest, shortMessage) {
ConstElementPtr stats_after = server.getStatistics()->get("zones")->
get("_SERVER_");
- std::map<std::string, unsigned long long int> expect;
+ std::map<std::string, uint64_t> expect;
expect["request.v4"] = 1;
expect["request.udp"] = 1;
checkStatisticsCounters(stats_after, expect);
@@ -359,7 +359,7 @@ TEST_F(AuthSrvTest, response) {
ConstElementPtr stats_after = server.getStatistics()->get("zones")->
get("_SERVER_");
- std::map<std::string, unsigned long long int> expect;
+ std::map<std::string, uint64_t> expect;
expect["request.v4"] = 3;
expect["request.udp"] = 3;
checkStatisticsCounters(stats_after, expect);
@@ -370,7 +370,7 @@ TEST_F(AuthSrvTest, shortQuestion) {
shortQuestion();
ConstElementPtr stats_after = server.getStatistics()->get("zones")->
get("_SERVER_");
- std::map<std::string, unsigned long long int> expect;
+ std::map<std::string, uint64_t> expect;
expect["request.v4"] = 1;
expect["request.udp"] = 1;
expect["opcode.query"] = 1;
@@ -385,7 +385,7 @@ TEST_F(AuthSrvTest, shortAnswer) {
shortAnswer();
ConstElementPtr stats_after = server.getStatistics()->get("zones")->
get("_SERVER_");
- std::map<std::string, unsigned long long int> expect;
+ std::map<std::string, uint64_t> expect;
expect["request.v4"] = 1;
expect["request.udp"] = 1;
expect["opcode.query"] = 1;
@@ -401,7 +401,7 @@ TEST_F(AuthSrvTest, ednsBadVers) {
ConstElementPtr stats_after = server.getStatistics()->get("zones")->
get("_SERVER_");
- std::map<std::string, unsigned long long int> expect;
+ std::map<std::string, uint64_t> expect;
expect["request.v4"] = 1;
expect["request.badednsver"] = 1;
expect["request.udp"] = 1;
@@ -431,7 +431,7 @@ TEST_F(AuthSrvTest, AXFRSuccess) {
ConstElementPtr stats_after = server.getStatistics()->get("zones")->
get("_SERVER_");
- std::map<std::string, unsigned long long int> expect;
+ std::map<std::string, uint64_t> expect;
expect["request.v4"] = 1;
expect["request.tcp"] = 1;
expect["opcode.query"] = 1;
@@ -473,7 +473,7 @@ TEST_F(AuthSrvTest, TSIGSignedBadKey) {
checkAllRcodeCountersZeroExcept(Rcode::NOTAUTH(), 1);
ConstElementPtr stats_after = server.getStatistics()->get("zones")->
get("_SERVER_");
- std::map<std::string, unsigned long long int> expect;
+ std::map<std::string, uint64_t> expect;
expect["request.v4"] = 1;
expect["request.tsig"] = 1;
expect["request.badsig"] = 1;
@@ -519,7 +519,7 @@ TEST_F(AuthSrvTest, TSIGBadSig) {
ConstElementPtr stats_after = server.getStatistics()->get("zones")->
get("_SERVER_");
- std::map<std::string, unsigned long long int> expect;
+ std::map<std::string, uint64_t> expect;
expect["request.v4"] = 1;
expect["request.tsig"] = 1;
expect["request.badsig"] = 1;
@@ -568,7 +568,7 @@ TEST_F(AuthSrvTest, TSIGCheckFirst) {
ConstElementPtr stats_after = server.getStatistics()->get("zones")->
get("_SERVER_");
- std::map<std::string, unsigned long long int> expect;
+ std::map<std::string, uint64_t> expect;
expect["request.v4"] = 1;
expect["request.tsig"] = 1;
expect["request.badsig"] = 1;
@@ -738,7 +738,7 @@ TEST_F(AuthSrvTest, notify) {
ConstElementPtr stats_after = server.getStatistics()->get("zones")->
get("_SERVER_");
- std::map<std::string, unsigned long long int> expect;
+ std::map<std::string, uint64_t> expect;
expect["request.v4"] = 1;
expect["request.udp"] = 1;
expect["opcode.notify"] = 1;
@@ -769,7 +769,7 @@ TEST_F(AuthSrvTest, notifyForCHClass) {
ConstElementPtr stats_after = server.getStatistics()->get("zones")->
get("_SERVER_");
- std::map<std::string, unsigned long long int> expect;
+ std::map<std::string, uint64_t> expect;
expect["request.v4"] = 1;
expect["request.udp"] = 1;
expect["opcode.notify"] = 1;
@@ -794,7 +794,7 @@ TEST_F(AuthSrvTest, notifyEmptyQuestion) {
ConstElementPtr stats_after = server.getStatistics()->get("zones")->
get("_SERVER_");
- std::map<std::string, unsigned long long int> expect;
+ std::map<std::string, uint64_t> expect;
expect["request.v4"] = 1;
expect["request.udp"] = 1;
expect["opcode.notify"] = 1;
@@ -1032,7 +1032,7 @@ TEST_F(AuthSrvTest, TSIGSigned) {
checkAllRcodeCountersZeroExcept(Rcode::NOERROR(), 1);
ConstElementPtr stats_after = server.getStatistics()->get("zones")->
get("_SERVER_");
- std::map<std::string, unsigned long long int> expect;
+ std::map<std::string, uint64_t> expect;
expect["request.v4"] = 1;
expect["request.tsig"] = 1;
expect["request.udp"] = 1;
@@ -1156,7 +1156,7 @@ TEST_F(AuthSrvTest, datasourceFail) {
checkAllRcodeCountersZeroExcept(Rcode::SERVFAIL(), 1);
ConstElementPtr stats = server.getStatistics()->get("zones")->
get("_SERVER_");
- std::map<std::string, unsigned long long int> expect;
+ std::map<std::string, uint64_t> expect;
expect["request.v4"] = 1;
expect["request.udp"] = 1;
expect["opcode.query"] = 1;
@@ -1232,7 +1232,7 @@ TEST_F(AuthSrvTest, emptyZone) {
checkAllRcodeCountersZeroExcept(Rcode::SERVFAIL(), 1);
ConstElementPtr stats = server.getStatistics()->get("zones")->
get("_SERVER_");
- std::map<std::string, unsigned long long int> expect;
+ std::map<std::string, uint64_t> expect;
expect["request.v4"] = 1;
expect["request.udp"] = 1;
expect["opcode.query"] = 1;
@@ -1309,7 +1309,7 @@ TEST_F(AuthSrvTest, queryCounterTruncTest) {
ConstElementPtr stats_after = server.getStatistics()->
get("zones")->get("_SERVER_");
- std::map<std::string, unsigned long long int> expect;
+ std::map<std::string, uint64_t> expect;
expect["request.v4"] = 1;
expect["request.udp"] = 1;
expect["opcode.query"] = 1;
@@ -1332,7 +1332,7 @@ TEST_F(AuthSrvTest, queryCounterUDPNormal) {
ConstElementPtr stats_after = server.getStatistics()->
get("zones")->get("_SERVER_");
- std::map<std::string, unsigned long long int> expect;
+ std::map<std::string, uint64_t> expect;
expect["request.v4"] = 1;
expect["request.udp"] = 1;
expect["opcode.query"] = 1;
@@ -1355,7 +1355,7 @@ TEST_F(AuthSrvTest, queryCounterUDPNormalWithDNSSEC) {
ConstElementPtr stats_after = server.getStatistics()->
get("zones")->get("_SERVER_");
- std::map<std::string, unsigned long long int> expect;
+ std::map<std::string, uint64_t> expect;
expect["request.v4"] = 1;
expect["request.edns0"] = 1;
expect["request.udp"] = 1;
@@ -1383,7 +1383,7 @@ TEST_F(AuthSrvTest, queryCounterTCPNormal) {
ConstElementPtr stats_after = server.getStatistics()->
get("zones")->get("_SERVER_");
- std::map<std::string, unsigned long long int> expect;
+ std::map<std::string, uint64_t> expect;
expect["request.v4"] = 1;
expect["request.tcp"] = 1;
expect["opcode.query"] = 1;
@@ -1407,7 +1407,7 @@ TEST_F(AuthSrvTest, queryCounterTCPAXFR) {
ConstElementPtr stats_after = server.getStatistics()->
get("zones")->get("_SERVER_");
- std::map<std::string, unsigned long long int> expect;
+ std::map<std::string, uint64_t> expect;
expect["request.v4"] = 1;
expect["request.tcp"] = 1;
expect["opcode.query"] = 1;
@@ -1427,7 +1427,7 @@ TEST_F(AuthSrvTest, queryCounterTCPIXFR) {
ConstElementPtr stats_after = server.getStatistics()->
get("zones")->get("_SERVER_");
- std::map<std::string, unsigned long long int> expect;
+ std::map<std::string, uint64_t> expect;
expect["request.v4"] = 1;
expect["request.tcp"] = 1;
expect["opcode.query"] = 1;
diff --git a/src/bin/auth/tests/statistics_util.cc b/src/bin/auth/tests/statistics_util.cc
index 5a91994..8ebd5f9 100644
--- a/src/bin/auth/tests/statistics_util.cc
+++ b/src/bin/auth/tests/statistics_util.cc
@@ -18,10 +18,11 @@
#include <string>
#include <map>
+#include <sys/types.h>
namespace {
void
-flatten(std::map<std::string, unsigned long long int>& flat_map, const std::string& prefix,
+flatten(std::map<std::string, uint64_t>& flat_map, const std::string& prefix,
const isc::data::ConstElementPtr map_element)
{
std::map<std::string, isc::data::ConstElementPtr> map =
@@ -54,17 +55,17 @@ namespace unittest {
void
checkStatisticsCounters(const isc::data::ConstElementPtr counters,
- const std::map<std::string, unsigned long long int>& expect)
+ const std::map<std::string, uint64_t>& expect)
{
- std::map<std::string, unsigned long long int> stats_map;
+ std::map<std::string, uint64_t> stats_map;
flatten(stats_map, "", counters);
- for (std::map<std::string, unsigned long long int>::const_iterator
+ for (std::map<std::string, uint64_t>::const_iterator
i = stats_map.begin(), e = stats_map.end();
i != e;
++i)
{
- const unsigned long long int value =
+ const uint64_t value =
expect.find(i->first) == expect.end() ?
0 : expect.find(i->first)->second;
EXPECT_EQ(value, i->second) << "Expected counter "
diff --git a/src/bin/auth/tests/statistics_util.h b/src/bin/auth/tests/statistics_util.h
index a751b7d..c59c1ed 100644
--- a/src/bin/auth/tests/statistics_util.h
+++ b/src/bin/auth/tests/statistics_util.h
@@ -25,7 +25,7 @@ namespace unittest {
// are zero.
void
checkStatisticsCounters(const isc::data::ConstElementPtr counters,
- const std::map<std::string, unsigned long long int>& expect);
+ const std::map<std::string, uint64_t>& expect);
} // end of unittest
} // end of auth
diff --git a/src/lib/cc/data.h b/src/lib/cc/data.h
index e5387b1..26a9e0a 100644
--- a/src/lib/cc/data.h
+++ b/src/lib/cc/data.h
@@ -21,6 +21,7 @@
#include <boost/shared_ptr.hpp>
#include <stdexcept>
#include <exceptions/exceptions.h>
+#include <climits>
#include <stdint.h>
namespace isc { namespace data {
@@ -383,6 +384,13 @@ class IntElement : public Element {
public:
IntElement(int64_t v) : Element(integer), i(v) { }
int64_t intValue() const { return (i); }
+ uint64_t uint64Value() const {
+ if (i >= 0) {
+ return (i);
+ } else {
+ isc_throw(TypeError, "uint64Value() called on negative integer Element");
+ }
+ };
using Element::getValue;
bool getValue(int64_t& t) const { t = i; return (true); }
using Element::setValue;
@@ -397,6 +405,13 @@ class Uint64Element : public Element {
public:
Uint64Element(uint64_t v) : Element(uint64), i(v) { }
uint64_t uint64Value() const { return (i); }
+ int64_t intValue() const {
+ if (i <= LLONG_MAX) {
+ return (i);
+ } else {
+ isc_throw(TypeError, "intValue() called on uint64 Element");
+ }
+ };
using Element::getValue;
bool getValue(uint64_t& t) const { t = i; return (true); }
using Element::setValue;
More information about the bind10-changes
mailing list