diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2016-05-28 17:55:12 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2016-05-28 17:55:12 -0400 |
commit | 6dcdd23dd37ef12c87e71cf59ef01cd82432efe0 (patch) | |
tree | c8cfb5acb62c80f375bc37e7d4350382deea6a37 /src/mongo/bson/util | |
parent | d4ac5673ea3f6cef4ce9dbcec90e31813997a528 (diff) | |
download | mongo-6dcdd23dd37ef12c87e71cf59ef01cd82432efe0.tar.gz |
SERVER-23971 Clang-Format code
Diffstat (limited to 'src/mongo/bson/util')
-rw-r--r-- | src/mongo/bson/util/bson_check.h | 5 | ||||
-rw-r--r-- | src/mongo/bson/util/bson_check_test.cpp | 13 | ||||
-rw-r--r-- | src/mongo/bson/util/bson_extract.cpp | 33 | ||||
-rw-r--r-- | src/mongo/bson/util/bson_extract_test.cpp | 6 | ||||
-rw-r--r-- | src/mongo/bson/util/builder.h | 2 |
5 files changed, 38 insertions, 21 deletions
diff --git a/src/mongo/bson/util/bson_check.h b/src/mongo/bson/util/bson_check.h index 4f2585e9e75..dd4f59816ba 100644 --- a/src/mongo/bson/util/bson_check.h +++ b/src/mongo/bson/util/bson_check.h @@ -64,7 +64,8 @@ Status bsonCheckOnlyHasFields(StringData objectName, if (occurrences[i] > 1) { return Status(ErrorCodes::DuplicateKey, str::stream() << "Field " << *curr << " appears " << occurrences[i] - << " times in " << objectName); + << " times in " + << objectName); } } return Status::OK(); @@ -77,7 +78,7 @@ Status bsonCheckOnlyHasFields(StringData objectName, template <typename StringType, int N> Status bsonCheckOnlyHasFields(StringData objectName, const BSONObj& o, - const StringType(&legals)[N]) { + const StringType (&legals)[N]) { return bsonCheckOnlyHasFields(objectName, o, &legals[0], legals + N); } diff --git a/src/mongo/bson/util/bson_check_test.cpp b/src/mongo/bson/util/bson_check_test.cpp index f14da7fa459..18365f9ee62 100644 --- a/src/mongo/bson/util/bson_check_test.cpp +++ b/src/mongo/bson/util/bson_check_test.cpp @@ -49,19 +49,26 @@ TEST(BsonCheck, CheckHasOnlyLegalFields) { ASSERT_OK(bsonCheckOnlyHasFields("", BSON("aField" << "value" - << "thirdField" << 1 << "anotherField" << 2), + << "thirdField" + << 1 + << "anotherField" + << 2), legals)); ASSERT_OK(bsonCheckOnlyHasFields("", BSON("aField" << "value" - << "thirdField" << 1), + << "thirdField" + << 1), legals)); ASSERT_EQUALS(ErrorCodes::BadValue, bsonCheckOnlyHasFields("", BSON("aField" << "value" - << "illegal" << 4 << "thirdField" << 1), + << "illegal" + << 4 + << "thirdField" + << 1), legals)); } diff --git a/src/mongo/bson/util/bson_extract.cpp b/src/mongo/bson/util/bson_extract.cpp index 095185e4baa..b3ff37ca1b2 100644 --- a/src/mongo/bson/util/bson_extract.cpp +++ b/src/mongo/bson/util/bson_extract.cpp @@ -37,7 +37,8 @@ Status bsonExtractField(const BSONObj& object, StringData fieldName, BSONElement if (element.eoo()) return Status(ErrorCodes::NoSuchKey, mongoutils::str::stream() << "Missing expected field \"" - << fieldName.toString() << "\""); + << fieldName.toString() + << "\""); *outElement = element; return Status::OK(); } @@ -51,9 +52,11 @@ Status bsonExtractTypedField(const BSONObj& object, return status; if (type != outElement->type()) { return Status(ErrorCodes::TypeMismatch, - mongoutils::str::stream() - << "\"" << fieldName << "\" had the wrong type. Expected " - << typeName(type) << ", found " << typeName(outElement->type())); + mongoutils::str::stream() << "\"" << fieldName + << "\" had the wrong type. Expected " + << typeName(type) + << ", found " + << typeName(outElement->type())); } return Status::OK(); } @@ -81,7 +84,8 @@ Status bsonExtractBooleanFieldWithDefault(const BSONObj& object, } else if (!value.isNumber() && !value.isBoolean()) { return Status(ErrorCodes::TypeMismatch, mongoutils::str::stream() << "Expected boolean or number type for field \"" - << fieldName << "\", found " + << fieldName + << "\", found " << typeName(value.type())); } else { *out = value.trueValue(); @@ -155,11 +159,12 @@ Status bsonExtractIntegerField(const BSONObj& object, StringData fieldName, long } long long result = value.safeNumberLong(); if (result != value.numberDouble()) { - return Status(ErrorCodes::BadValue, - mongoutils::str::stream() - << "Expected field \"" << fieldName - << "\" to have a value " - "exactly representable as a 64-bit integer, but found " << value); + return Status( + ErrorCodes::BadValue, + mongoutils::str::stream() << "Expected field \"" << fieldName + << "\" to have a value " + "exactly representable as a 64-bit integer, but found " + << value); } *out = result; return Status::OK(); @@ -188,9 +193,11 @@ Status bsonExtractIntegerFieldWithDefaultIf(const BSONObj& object, return status; } if (!pred(*out)) { - return Status(ErrorCodes::BadValue, - mongoutils::str::stream() << "Invalid value in field \"" << fieldName - << "\": " << *out << ": " << predDescription); + return Status( + ErrorCodes::BadValue, + mongoutils::str::stream() << "Invalid value in field \"" << fieldName << "\": " << *out + << ": " + << predDescription); } return Status::OK(); } diff --git a/src/mongo/bson/util/bson_extract_test.cpp b/src/mongo/bson/util/bson_extract_test.cpp index 8ec13d1fbd1..9ef6a448e80 100644 --- a/src/mongo/bson/util/bson_extract_test.cpp +++ b/src/mongo/bson/util/bson_extract_test.cpp @@ -89,10 +89,12 @@ TEST(ExtractBSON, ExtractStringFieldWithDefault) { TEST(ExtractBSON, ExtractBooleanFieldWithDefault) { BSONObj obj1 = BSON("a" << 1 << "b" << "hello" - << "c" << true); + << "c" + << true); BSONObj obj2 = BSON("a" << 0 << "b" << "hello" - << "c" << false); + << "c" + << false); bool b; b = false; ASSERT_OK(bsonExtractBooleanFieldWithDefault(obj1, "a", false, &b)); diff --git a/src/mongo/bson/util/builder.h b/src/mongo/bson/util/builder.h index 1b43a69ad27..f440e9b8fcb 100644 --- a/src/mongo/bson/util/builder.h +++ b/src/mongo/bson/util/builder.h @@ -32,8 +32,8 @@ #include <cfloat> #include <sstream> #include <stdio.h> -#include <string> #include <string.h> +#include <string> #include "mongo/base/data_type_endian.h" |