BIND 10 trac438, updated. 18964f9374531c8f131065dcd53aefd998e080ac [trac438] Extended logging API tests
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Feb 1 19:10:04 UTC 2011
The branch, trac438 has been updated
via 18964f9374531c8f131065dcd53aefd998e080ac (commit)
from f70d352db01e774ad9561499f2205de3e66e8dbb (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 18964f9374531c8f131065dcd53aefd998e080ac
Author: Stephen Morris <stephen at isc.org>
Date: Tue Feb 1 19:07:48 2011 +0000
[trac438] Extended logging API tests
Added an explicit test for logging up a non-existent or invalid
symbol in the dictionary. Also added a test to ensure that multiple
MessageInitializer objects will all contribute their messages to
the global dictionary.
-----------------------------------------------------------------------
Summary of changes:
src/lib/log/tests/Makefile.am | 1 +
src/lib/log/tests/message_dictionary_unittest.cc | 26 ++++++++++++
src/lib/log/tests/message_initializer_unittest.cc | 21 ++++++++--
...ittest.cc => message_initializer_unittest_2.cc} | 44 ++++++--------------
4 files changed, 57 insertions(+), 35 deletions(-)
copy src/lib/log/tests/{message_initializer_unittest.cc => message_initializer_unittest_2.cc} (57%)
-----------------------------------------------------------------------
diff --git a/src/lib/log/tests/Makefile.am b/src/lib/log/tests/Makefile.am
index a99a6d3..01973c9 100644
--- a/src/lib/log/tests/Makefile.am
+++ b/src/lib/log/tests/Makefile.am
@@ -20,6 +20,7 @@ run_unittests_SOURCES += logger_unittest.cc
run_unittests_SOURCES += message_dictionary_unittest.cc
run_unittests_SOURCES += message_reader_unittest.cc
run_unittests_SOURCES += message_initializer_unittest.cc
+run_unittests_SOURCES += message_initializer_unittest_2.cc
run_unittests_SOURCES += strutil_unittest.cc
run_unittests_SOURCES += xdebuglevel_unittest.cc
run_unittests_SOURCES += run_unittests.cc
diff --git a/src/lib/log/tests/message_dictionary_unittest.cc b/src/lib/log/tests/message_dictionary_unittest.cc
index 829446d..78aa851 100644
--- a/src/lib/log/tests/message_dictionary_unittest.cc
+++ b/src/lib/log/tests/message_dictionary_unittest.cc
@@ -145,3 +145,29 @@ TEST_F(MessageDictionaryTest, LoadTest) {
EXPECT_EQ(string(""), dictionary2.getText(data2[4]));
EXPECT_EQ(0, duplicates.size());
}
+
+// Check for some non-existent items
+
+TEST_F(MessageDictionaryTest, Lookups) {
+ static const char* data[] = {
+ "ALPHA", "This is alpha",
+ "BETA", "This is beta",
+ "GAMMA", "This is gamma",
+ NULL
+ };
+
+ MessageDictionary dictionary;
+ vector<MessageID> duplicates = dictionary.load(data);
+ EXPECT_EQ(3, dictionary.size());
+ EXPECT_EQ(0, duplicates.size());
+
+ // Valid lookups
+ EXPECT_EQ(string("This is alpha"), dictionary.getText("ALPHA"));
+ EXPECT_EQ(string("This is beta"), dictionary.getText("BETA"));
+ EXPECT_EQ(string("This is gamma"), dictionary.getText("GAMMA"));
+
+ // ... and invalid ones
+ EXPECT_EQ(string(""), dictionary.getText("XYZZY"));
+ EXPECT_EQ(string(""), dictionary.getText(""));
+ EXPECT_EQ(string(""), dictionary.getText("\n\n\n"));
+}
diff --git a/src/lib/log/tests/message_initializer_unittest.cc b/src/lib/log/tests/message_initializer_unittest.cc
index b3cb82e..6a1019f 100644
--- a/src/lib/log/tests/message_initializer_unittest.cc
+++ b/src/lib/log/tests/message_initializer_unittest.cc
@@ -27,16 +27,26 @@ using namespace std;
// Declare a set of messages to go into the global dictionary.
namespace {
-const char* values[] = {
+const char* values1[] = {
"GLOBAL1", "global message one",
"GLOBAL2", "global message two",
NULL
};
+
+const char* values2[] = {
+ "GLOBAL3", "global message three",
+ "GLOBAL4", "global message four",
+ NULL
+};
+
}
-// Statically initialize the global dictionary with those messages.
-MessageInitializer init_message_initializer_unittest(values);
+// Statically initialize the global dictionary with those messages. Three sets
+// are used to check that the declaration of separate initializer objects really// does combine the messages. (The third set is declared in the separately-
+// compiled file message_identifier_initializer_unittest_2.cc.)
+MessageInitializer init_message_initializer_unittest_1(values1);
+MessageInitializer init_message_initializer_unittest_2(values2);
class MessageInitializerTest : public ::testing::Test {
@@ -55,5 +65,8 @@ TEST_F(MessageInitializerTest, MessageTest) {
EXPECT_EQ(string("global message one"), global->getText("GLOBAL1"));
EXPECT_EQ(string("global message two"), global->getText("GLOBAL2"));
- EXPECT_EQ(string(""), global->getText(""));
+ EXPECT_EQ(string("global message three"), global->getText("GLOBAL3"));
+ EXPECT_EQ(string("global message four"), global->getText("GLOBAL4"));
+ EXPECT_EQ(string("global message five"), global->getText("GLOBAL5"));
+ EXPECT_EQ(string("global message six"), global->getText("GLOBAL6"));
}
diff --git a/src/lib/log/tests/message_initializer_unittest_2.cc b/src/lib/log/tests/message_initializer_unittest_2.cc
new file mode 100644
index 0000000..c005033
--- /dev/null
+++ b/src/lib/log/tests/message_initializer_unittest_2.cc
@@ -0,0 +1,41 @@
+// Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+// $Id: base64_unittest.cc 2549 2010-07-20 19:09:37Z jinmei $
+
+// The sole purpose of this file is to provide a set of message definitions
+// in a separate compilation unit from the one in which their presence is
+// checked. This tests that merely declaring the MessageInitializer object
+// is enough to include the definitions in the global dictionary.
+
+#include <log/message_initializer.h>
+
+using namespace isc::log;
+
+// Declare a set of messages to go into the global dictionary.
+
+namespace {
+
+const char* values3[] = {
+ "GLOBAL5", "global message five",
+ "GLOBAL6", "global message six",
+ NULL
+};
+
+}
+
+// Statically initialize the global dictionary with those messages.
+// Three sets are used to check that the declaration of separate
+// initializer objects really does combine the messages.
+MessageInitializer init_message_initializer_unittest_3(values3);
More information about the bind10-changes
mailing list