BIND 10 trac2430, updated. d8558bef68e5c67785deaceb23046c168afca4c4 [2430] Add generateAtEnd unittest
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Feb 14 13:50:46 UTC 2014
The branch, trac2430 has been updated
via d8558bef68e5c67785deaceb23046c168afca4c4 (commit)
via a96232b3826660654f5afe4bb6961e6929635e2a (commit)
via 9aa52ecbbc7366e0246cbc554db9d3fccdf47b3b (commit)
from 4df951747393f5e59babd70ecba190b6dcb2fd74 (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 d8558bef68e5c67785deaceb23046c168afca4c4
Author: Mukund Sivaraman <muks at isc.org>
Date: Fri Feb 14 19:19:53 2014 +0530
[2430] Add generateAtEnd unittest
commit a96232b3826660654f5afe4bb6961e6929635e2a
Author: Mukund Sivaraman <muks at isc.org>
Date: Fri Feb 14 19:14:58 2014 +0530
[2430] Add comment about before and after scaffolding in test
commit 9aa52ecbbc7366e0246cbc554db9d3fccdf47b3b
Author: Mukund Sivaraman <muks at isc.org>
Date: Fri Feb 14 19:11:58 2014 +0530
[2430] Rename argument i to num
-----------------------------------------------------------------------
Summary of changes:
src/lib/dns/master_loader.cc | 22 +++++++++++-----------
src/lib/dns/tests/master_loader_unittest.cc | 20 ++++++++++++++++++++
2 files changed, 31 insertions(+), 11 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dns/master_loader.cc b/src/lib/dns/master_loader.cc
index 6073125..6ca4aeb 100644
--- a/src/lib/dns/master_loader.cc
+++ b/src/lib/dns/master_loader.cc
@@ -447,13 +447,13 @@ public:
namespace { // begin unnamed namespace
std::string
-genNibbles(int i, unsigned int width, bool uppercase) {
+genNibbles(int num, unsigned int width, bool uppercase) {
static const char *hex = "0123456789abcdef0123456789ABCDEF";
std::string rstr;
do {
- char ch = hex[(i & 0x0f) + (uppercase ? 16 : 0)];
- i >>= 4;
+ char ch = hex[(num & 0x0f) + (uppercase ? 16 : 0)];
+ num >>= 4;
rstr.push_back(ch);
if (width > 0) {
@@ -463,14 +463,14 @@ genNibbles(int i, unsigned int width, bool uppercase) {
// If width is non zero then we need to add a label separator.
// If value is non zero then we need to add another label and
// that requires a label separator.
- if (width > 0 || i != 0) {
+ if (width > 0 || num != 0) {
rstr.push_back('.');
if (width > 0) {
--width;
}
}
- } while ((i != 0) || (width > 0));
+ } while ((num != 0) || (width > 0));
return (rstr);
}
@@ -479,7 +479,7 @@ genNibbles(int i, unsigned int width, bool uppercase) {
std::string
MasterLoader::MasterLoaderImpl::generateForIter(const std::string& str,
- const int i)
+ const int num)
{
std::string rstr;
@@ -494,7 +494,7 @@ MasterLoader::MasterLoaderImpl::generateForIter(const std::string& str,
}
if (*it != '{') {
- rstr += boost::str(boost::format("%d") % i);
+ rstr += boost::str(boost::format("%d") % num);
} else {
const char* scan_str =
str.c_str() + std::distance(str.begin(), it);
@@ -505,23 +505,23 @@ MasterLoader::MasterLoaderImpl::generateForIter(const std::string& str,
&offset, &width, base);
switch (n) {
case 1:
- rstr += boost::str(boost::format("%d") % (i + offset));
+ rstr += boost::str(boost::format("%d") % (num + offset));
break;
case 2: {
const std::string fmt =
boost::str(boost::format("%%0%ud") % width);
- rstr += boost::str(boost::format(fmt) % (i + offset));
+ rstr += boost::str(boost::format(fmt) % (num + offset));
break;
}
case 3:
if ((base[0] == 'n') || (base[0] == 'N')) {
- rstr += genNibbles(i + offset, width, (base[0] == 'N'));
+ rstr += genNibbles(num + offset, width, (base[0] == 'N'));
} else {
const std::string fmt =
boost::str(boost::format("%%0%u%c") % width % base[0]);
- rstr += boost::str(boost::format(fmt) % (i + offset));
+ rstr += boost::str(boost::format(fmt) % (num + offset));
}
break;
diff --git a/src/lib/dns/tests/master_loader_unittest.cc b/src/lib/dns/tests/master_loader_unittest.cc
index 3bfd9f9..ee747c9 100644
--- a/src/lib/dns/tests/master_loader_unittest.cc
+++ b/src/lib/dns/tests/master_loader_unittest.cc
@@ -337,6 +337,9 @@ TEST_F(MasterLoaderTest, generate) {
EXPECT_TRUE(loader_->loadedSucessfully());
EXPECT_TRUE(errors_.empty());
+ // The "before" and "after" scaffolding below checks that no
+ // extra records are added by $GENERATE outside the requested
+ // range.
checkRR("before.example.org", RRType::A(), "192.0.2.0");
checkRR("host3.example.org", RRType::A(), "192.0.2.3");
checkRR("host4.example.org", RRType::A(), "192.0.2.4");
@@ -395,6 +398,23 @@ TEST_F(MasterLoaderTest, generateInMiddle) {
checkRR("num10-host.example.org", RRType::TXT(), "This is 10 pomegranate");
}
+TEST_F(MasterLoaderTest, generateAtEnd) {
+ // $ is at the end
+ const string input =
+ "$ORIGIN example.org.\n"
+ "$GENERATE 9-10 num$-host 3600 TXT Pomegranate$\n";
+ stringstream ss(input);
+ setLoader(ss, Name("example.org."), RRClass::IN(),
+ MasterLoader::MANY_ERRORS);
+
+ loader_->load();
+ EXPECT_TRUE(loader_->loadedSucessfully());
+ EXPECT_TRUE(errors_.empty());
+
+ checkRR("num9-host.example.org", RRType::TXT(), "Pomegranate9");
+ checkRR("num10-host.example.org", RRType::TXT(), "Pomegranate10");
+}
+
TEST_F(MasterLoaderTest, generateStripsQuotes) {
const string input =
"$ORIGIN example.org.\n"
More information about the bind10-changes
mailing list