BIND 10 trac1975, updated. 88cbe7028f70266945fe6b53a46e235b4c9eca83 [1975] use EXPECT_TRUE with == inside it, instead of EXPECT_EQ to make it build.
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Jun 8 22:43:23 UTC 2012
The branch, trac1975 has been updated
via 88cbe7028f70266945fe6b53a46e235b4c9eca83 (commit)
via 115179c9044864a193f2b3c78f0826dd03ed8cad (commit)
from f661e074e4b4b09acc21ffc90155a48e64c11de4 (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 88cbe7028f70266945fe6b53a46e235b4c9eca83
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Fri Jun 8 15:41:16 2012 -0700
[1975] use EXPECT_TRUE with == inside it, instead of EXPECT_EQ to make it build.
Since no operator<< for SearchResult is defined, EXPECT_EQ doesn't compile,
at least not on some environment. This is not the only way to fix it, but
reviewing it without having buildable tree is quite difficult, so I'm
tentatively making the easiest fix and committing it. Feel free to override
it.
commit 115179c9044864a193f2b3c78f0826dd03ed8cad
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Fri Jun 8 15:18:58 2012 -0700
[1975] editorial fixes: constify, brace position, newlines, typo.
I added newlines before the start of doxygen doc. We don't have it our
guideline, but I thought we agreed before we add to insert a new line here
for readability.
-----------------------------------------------------------------------
Summary of changes:
src/lib/datasrc/container.cc | 10 ++++----
src/lib/datasrc/container.h | 16 ++++++++++--
src/lib/datasrc/tests/container_unittest.cc | 35 +++++++++++++++------------
3 files changed, 38 insertions(+), 23 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/container.cc b/src/lib/datasrc/container.cc
index 9455c0d..6e0d332 100644
--- a/src/lib/datasrc/container.cc
+++ b/src/lib/datasrc/container.cc
@@ -58,8 +58,7 @@ ConfigurableContainer::configure(const ConstElementPtr& config, bool) {
// ready. So just put it there and let the old one die when we exit
// the scope.
data_sources_.swap(new_data_sources);
- }
- catch (const TypeError& te) {
+ } catch (const TypeError& te) {
isc_throw(ConfigurationError, "Malformed configuration at data source "
"no. " << i << ": " << te.what());
}
@@ -67,7 +66,7 @@ ConfigurableContainer::configure(const ConstElementPtr& config, bool) {
Container::SearchResult
ConfigurableContainer::search(const dns::Name& name, bool want_exact_match,
- bool ) const
+ bool) const
{
// Nothing found yet.
// Pointer is used as the SearchResult can't be assigned.
@@ -80,7 +79,8 @@ ConfigurableContainer::search(const dns::Name& name, bool want_exact_match,
// zones and zones expected to be in the real data source. If it is
// the cached one, provide the cached one. If it is in the external
// data source, use the datasource and don't provide the finder yet.
- DataSourceClient::FindResult result(info.data_src_->findZone(name));
+ const DataSourceClient::FindResult result(
+ info.data_src_->findZone(name));
switch (result.code) {
case result::SUCCESS: {
// If we found an exact match, we have no hope to getting
@@ -95,7 +95,7 @@ ConfigurableContainer::search(const dns::Name& name, bool want_exact_match,
if (!want_exact_match) {
// In case we have a partial match, check if it is better
// than what we have. If so, replace it.
- uint8_t labels(
+ const uint8_t labels(
result.zone_finder->getOrigin().getLabelCount());
if (labels > candidate->matched_labels_) {
// This one is strictly better. Replace it.
diff --git a/src/lib/datasrc/container.h b/src/lib/datasrc/container.h
index b8492e0..f8792e4 100644
--- a/src/lib/datasrc/container.h
+++ b/src/lib/datasrc/container.h
@@ -46,7 +46,7 @@ typedef boost::shared_ptr<DataSourceClientContainer>
/// is the ConfigurableContainer.
class Container : public boost::noncopyable {
protected:
- /// \brief Constructur.
+ /// \brief Constructor.
///
/// It is protected to prevent accidental creation of the abstract base
/// class.
@@ -70,6 +70,7 @@ public:
matched_labels_(matched_labels),
exact_match_(exact_match)
{ }
+
/// \brief Negative answer constructor.
///
/// This conscructs a result for negative answer. Both pointers are
@@ -79,6 +80,7 @@ public:
matched_labels_(0),
exact_match_(false)
{ }
+
/// \brief Comparison operator.
///
/// It is needed for tests and it might be of some use elsewhere
@@ -89,11 +91,13 @@ public:
matched_labels_ == other.matched_labels_ &&
exact_match_ == other.exact_match_);
}
+
/// \brief The found data source.
///
/// The data source containing the best matching zone. If no such
/// data source exists, this is NULL pointer.
DataSourceClient* const datasrc_;
+
/// \brief The finder for the requested zone.
///
/// This is the finder corresponding to the best matching zone.
@@ -102,15 +106,18 @@ public:
///
/// \see search
const ZoneFinderPtr finder_;
+
/// \brief Number of matching labels.
///
/// The number of labels the result have in common with the queried
/// name of zone.
const uint8_t matched_labels_;
+
/// \brief If the result is an exact match.
const bool exact_match_;
};
- /// \brief Search for a zone thourgh the data sources.
+
+ /// \brief Search for a zone through the data sources.
///
/// This searches the contained data sources for a one that best matches
/// the zone name.
@@ -181,6 +188,7 @@ public:
Exception(file, line, what)
{ }
};
+
/// \brief Sets the configuration.
///
/// This fills the Container with data sources corresponding to the
@@ -201,6 +209,7 @@ public:
/// sense.
void configure(const data::ConstElementPtr& configuration,
bool allow_cache);
+
/// \brief Implementation of the Container::search.
virtual SearchResult search(const dns::Name& zone,
bool want_exact_match = false,
@@ -213,6 +222,7 @@ public:
DataSourceClient* data_src_;
DataSourceClientContainerPtr container_;
};
+
/// \brief The collection of data sources.
typedef std::vector<DataSourceInfo> DataSources;
protected:
@@ -221,11 +231,13 @@ protected:
/// All our data sources are stored here. It is protected to let the
/// tests in.
DataSources data_sources_;
+
/// \brief Convenience type alias.
///
/// \see getDataSource
typedef std::pair<DataSourceClient*, DataSourceClientContainerPtr>
DataSourcePair;
+
/// \brief Create a data source of given type and configuration.
///
/// This is a thin wrapper around the DataSourceClientContainer
diff --git a/src/lib/datasrc/tests/container_unittest.cc b/src/lib/datasrc/tests/container_unittest.cc
index 7528efe..a4aec1c 100644
--- a/src/lib/datasrc/tests/container_unittest.cc
+++ b/src/lib/datasrc/tests/container_unittest.cc
@@ -252,14 +252,17 @@ TEST_F(ContainerTest, emptyContainer) {
// match.
TEST_F(ContainerTest, emptySearch) {
// No matter what we try, we don't get an answer.
- EXPECT_EQ(negativeResult_, container_->search(Name("example.org"), false,
- false));
- EXPECT_EQ(negativeResult_, container_->search(Name("example.org"), false,
- true));
- EXPECT_EQ(negativeResult_, container_->search(Name("example.org"), true,
- false));
- EXPECT_EQ(negativeResult_, container_->search(Name("example.org"), true,
- true));
+
+ // Note: we don't have operator<< for the result class, so we cannot use
+ // EXPECT_EQ. Same for other similar cases.
+ EXPECT_TRUE(negativeResult_ == container_->search(Name("example.org"),
+ false, false));
+ EXPECT_TRUE(negativeResult_ == container_->search(Name("example.org"),
+ false, true));
+ EXPECT_TRUE(negativeResult_ == container_->search(Name("example.org"), true,
+ false));
+ EXPECT_TRUE(negativeResult_ == container_->search(Name("example.org"), true,
+ true));
}
// Put a single data source inside the container and check it can find an
@@ -267,21 +270,21 @@ TEST_F(ContainerTest, emptySearch) {
TEST_F(ContainerTest, singleDSExactMatch) {
container_->dataSources().push_back(ds_info_[0]);
// This zone is not there
- EXPECT_EQ(negativeResult_, container_->search(Name("org."), true));
+ EXPECT_TRUE(negativeResult_ == container_->search(Name("org."), true));
// But this one is, so check it.
positiveResult(container_->search(Name("example.org"), true),
ds_[0], Name("example.org"), true, "Exact match");
// When asking for a sub zone of a zone there, we get nothing
// (we want exact match, this would be partial one)
- EXPECT_EQ(negativeResult_, container_->search(Name("sub.example.org."),
- true));
+ EXPECT_TRUE(negativeResult_ == container_->search(Name("sub.example.org."),
+ true));
}
// When asking for a partial match, we get all that the exact one, but more.
TEST_F(ContainerTest, singleDSBestMatch) {
container_->dataSources().push_back(ds_info_[0]);
// This zone is not there
- EXPECT_EQ(negativeResult_, container_->search(Name("org.")));
+ EXPECT_TRUE(negativeResult_ == container_->search(Name("org.")));
// But this one is, so check it.
positiveResult(container_->search(Name("example.org")),
ds_[0], Name("example.org"), true, "Exact match");
@@ -304,7 +307,7 @@ TEST_F(ContainerTest, multiExactMatch) {
SCOPED_TRACE(test_names[i]);
multiConfiguration(i);
// Something that is nowhere there
- EXPECT_EQ(negativeResult_, container_->search(Name("org."), true));
+ EXPECT_TRUE(negativeResult_ == container_->search(Name("org."), true));
// This one is there exactly.
positiveResult(container_->search(Name("example.org"), true),
ds_[0], Name("example.org"), true, "Exact match");
@@ -313,8 +316,8 @@ TEST_F(ContainerTest, multiExactMatch) {
ds_[1], Name("sub.example.org"), true,
"Subdomain match");
// But this one is in neither data source.
- EXPECT_EQ(negativeResult_, container_->search(Name("sub.example.com."),
- true));
+ EXPECT_TRUE(negativeResult_ ==
+ container_->search(Name("sub.example.com."), true));
}
}
@@ -324,7 +327,7 @@ TEST_F(ContainerTest, multiBestMatch) {
SCOPED_TRACE(test_names[i]);
multiConfiguration(i);
// Something that is nowhere there
- EXPECT_EQ(negativeResult_, container_->search(Name("org.")));
+ EXPECT_TRUE(negativeResult_ == container_->search(Name("org.")));
// This one is there exactly.
positiveResult(container_->search(Name("example.org")),
ds_[0], Name("example.org"), true, "Exact match");
More information about the bind10-changes
mailing list