diff options
author | Andrew Morrow <acm@10gen.com> | 2013-03-26 15:32:03 -0400 |
---|---|---|
committer | Andrew Morrow <acm@10gen.com> | 2013-03-27 14:42:17 -0400 |
commit | 45bedc3c887794a25dc74325fecaa654ea160506 (patch) | |
tree | 2f1e444c1d453e3c99a9f6c82af55289693b325c /src/mongo/bson/mutable/mutable_bson_test_utils.cpp | |
parent | 2ef273f283c7d45b9dfa55f5adf14f2b63069dc7 (diff) | |
download | mongo-45bedc3c887794a25dc74325fecaa654ea160506.tar.gz |
SERVER-8046 Fix broken mutable bson algorithm
Diffstat (limited to 'src/mongo/bson/mutable/mutable_bson_test_utils.cpp')
-rw-r--r-- | src/mongo/bson/mutable/mutable_bson_test_utils.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/mongo/bson/mutable/mutable_bson_test_utils.cpp b/src/mongo/bson/mutable/mutable_bson_test_utils.cpp new file mode 100644 index 00000000000..65306db5de1 --- /dev/null +++ b/src/mongo/bson/mutable/mutable_bson_test_utils.cpp @@ -0,0 +1,47 @@ +/* Copyright 2013 10gen Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "mongo/platform/basic.h" + +#include "mongo/bson/mutable/mutable_bson_test_utils.h" + +#include <ostream> + +#include "mongo/bson/mutable/const_element.h" + +namespace mongo { +namespace mutablebson { + + std::ostream& operator<<(std::ostream& stream, const ConstElement& elt) { + stream << "Element("<< static_cast<const void*>(&elt.getDocument()) << ", "; + if (elt.ok()) + stream << elt.getIdx(); + else + stream << "kInvalidIndex"; + stream << ")"; + + if (elt.ok()) { + stream << " of type '" << typeName(elt.getType()) << "'"; + if (elt.hasValue()) + stream << " with accessible value '" << elt.getValue() << "'"; + else + stream << " with no accessible value"; + } + + return stream; + } + +} // namespace mutablebson +} // namespace mongo |