BIND 10 trac1112, updated. f0274b7451761b2dc48c0be148ecd8563c9800da [trac1112] Replace IS_DIGIT macro with function in anonymouse namespace. Replace TEST_F with TEST in unit tests. Update the description of InvalidRdataTest exception.
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Sep 20 02:39:31 UTC 2011
The branch, trac1112 has been updated
via f0274b7451761b2dc48c0be148ecd8563c9800da (commit)
from 9f441d72a245e3ccce2ee014adaa0ad62e7b0d29 (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 f0274b7451761b2dc48c0be148ecd8563c9800da
Author: Ocean Wang <wanghaidong at cnnic.cn>
Date: Tue Sep 20 10:36:09 2011 +0800
[trac1112] Replace IS_DIGIT macro with function in anonymouse namespace. Replace TEST_F with TEST in unit tests. Update the description of InvalidRdataTest exception.
-----------------------------------------------------------------------
Summary of changes:
src/lib/dns/character_string.cc | 15 +++++++++------
src/lib/dns/tests/character_string_unittest.cc | 8 +++-----
2 files changed, 12 insertions(+), 11 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dns/character_string.cc b/src/lib/dns/character_string.cc
index ae2ad7a..db83eb6 100644
--- a/src/lib/dns/character_string.cc
+++ b/src/lib/dns/character_string.cc
@@ -21,7 +21,11 @@ using namespace isc::dns::rdata;
namespace isc {
namespace dns {
-#define IS_DIGIT(c) (('0' <= (c)) && ((c) <= '9'))
+namespace {
+bool isDigit(char c) {
+ return ('0' <= c) && (c <= '9');
+}
+}
std::string
characterstr::getNextCharacterString(const std::string& input_str,
@@ -50,20 +54,19 @@ characterstr::getNextCharacterString(const std::string& input_str,
if (*input_iterator == '\\') {
if (input_iterator + 1 == input_str.end()) {
isc_throw(InvalidRdataText, "<character-string> ended \
- exceptionally.");
+ prematurely.");
} else {
- if (IS_DIGIT(*(input_iterator + 1))) {
+ if (isDigit(*(input_iterator + 1))) {
// \DDD where each D is a digit. It its the octet
// corresponding to the decimal number described by DDD
if (input_iterator + 3 >= input_str.end()) {
isc_throw(InvalidRdataText, "<character-string> ended \
- exceptionally.");
+ prematurely.");
} else {
int n = 0;
++input_iterator;
for (int i = 0; i < 3; ++i) {
- if (('0' <= *input_iterator) &&
- (*input_iterator <= '9')) {
+ if (isDigit(*input_iterator)) {
n = n*10 + (*input_iterator - '0');
++input_iterator;
} else {
diff --git a/src/lib/dns/tests/character_string_unittest.cc b/src/lib/dns/tests/character_string_unittest.cc
index 83dbf92..5fed9eb 100644
--- a/src/lib/dns/tests/character_string_unittest.cc
+++ b/src/lib/dns/tests/character_string_unittest.cc
@@ -28,8 +28,6 @@ using namespace isc::dns::characterstr;
using namespace isc::dns::rdata;
namespace {
-class CharacterStringTest : public ::testing::Test {
-};
class CharacterString {
public:
@@ -42,7 +40,7 @@ private:
string characterStr_;
};
-TEST_F(CharacterStringTest, testNormalCase) {
+TEST(CharacterStringTest, testNormalCase) {
CharacterString cstr1("foo");
EXPECT_EQ(string("foo"), cstr1.str());
@@ -59,7 +57,7 @@ TEST_F(CharacterStringTest, testNormalCase) {
EXPECT_EQ(string("foo\""), cstr4.str());
}
-TEST_F(CharacterStringTest, testBadCase) {
+TEST(CharacterStringTest, testBadCase) {
// The <character-string> that started with quotes should also be ended
// with quotes
EXPECT_THROW(CharacterString cstr("\"foo"), InvalidRdataText);
@@ -72,7 +70,7 @@ TEST_F(CharacterStringTest, testBadCase) {
EXPECT_THROW(CharacterString cstr(str), CharStringTooLong);
}
-TEST_F(CharacterStringTest, testEscapeCharacter) {
+TEST(CharacterStringTest, testEscapeCharacter) {
CharacterString cstr1("foo\\bar");
EXPECT_EQ(string("foobar"), cstr1.str());
More information about the bind10-changes
mailing list