summaryrefslogtreecommitdiff
path: root/src/mongo/idl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/idl')
-rw-r--r--src/mongo/idl/config_option_test.cpp22
-rw-r--r--src/mongo/idl/idl_parser.cpp20
-rw-r--r--src/mongo/idl/idl_parser.h9
-rw-r--r--src/mongo/idl/idl_test.cpp329
-rw-r--r--src/mongo/idl/server_parameter_specialized_test.cpp12
-rw-r--r--src/mongo/idl/server_parameter_with_storage.h11
6 files changed, 131 insertions, 272 deletions
diff --git a/src/mongo/idl/config_option_test.cpp b/src/mongo/idl/config_option_test.cpp
index 9e94434da85..e3e8b8782df 100644
--- a/src/mongo/idl/config_option_test.cpp
+++ b/src/mongo/idl/config_option_test.cpp
@@ -501,8 +501,7 @@ TEST(RedactionBSON, Strings) {
<< "also not a password"
<< "test.config.opt16depr2"
<< "this password should also be censored"
- << "lastarg"
- << false);
+ << "lastarg" << false);
BSONObj res = BSON("firstarg"
<< "not a password"
@@ -514,8 +513,7 @@ TEST(RedactionBSON, Strings) {
<< "also not a password"
<< "test.config.opt16depr2"
<< "<password>"
- << "lastarg"
- << false);
+ << "lastarg" << false);
cmdline_utils::censorBSONObj(&obj);
ASSERT_BSONOBJ_EQ(res, obj);
@@ -535,8 +533,7 @@ TEST(RedactionBSON, Arrays) {
<< "test.config.opt16depr2"
<< BSON_ARRAY("first censored password"
<< "next censored password")
- << "lastarg"
- << false);
+ << "lastarg" << false);
BSONObj res = BSON("firstarg"
<< "not a password"
@@ -551,8 +548,7 @@ TEST(RedactionBSON, Arrays) {
<< "test.config.opt16depr2"
<< BSON_ARRAY("<password>"
<< "<password>")
- << "lastarg"
- << false);
+ << "lastarg" << false);
cmdline_utils::censorBSONObj(&obj);
ASSERT_BSONOBJ_EQ(res, obj);
@@ -571,8 +567,7 @@ TEST(RedactionBSON, SubObjects) {
<< "next censored password")
<< "opt16depr"
<< "should be censored too"))
- << "lastarg"
- << false);
+ << "lastarg" << false);
BSONObj res = BSON("firstarg"
<< "not a password"
@@ -586,8 +581,7 @@ TEST(RedactionBSON, SubObjects) {
<< "<password>")
<< "opt16depr"
<< "<password>"))
- << "lastarg"
- << false);
+ << "lastarg" << false);
cmdline_utils::censorBSONObj(&obj);
ASSERT_BSONOBJ_EQ(res, obj);
@@ -620,7 +614,9 @@ TEST(ConfigOptionNoInit, Opt1) {
ASSERT_OK(addIDLTestConfigs(&options));
const std::vector<std::string> argv({
- "mongod", "--testConfigNoInitOpt1", "Hello",
+ "mongod",
+ "--testConfigNoInitOpt1",
+ "Hello",
});
moe::Environment parsed;
ASSERT_OK(moe::OptionsParser().run(options, argv, {}, &parsed));
diff --git a/src/mongo/idl/idl_parser.cpp b/src/mongo/idl/idl_parser.cpp
index 0a45ac52709..135d49b784b 100644
--- a/src/mongo/idl/idl_parser.cpp
+++ b/src/mongo/idl/idl_parser.cpp
@@ -76,9 +76,7 @@ bool IDLParserErrorContext::checkAndAssertTypeSlowPath(const BSONElement& elemen
std::string path = getElementPath(element);
uasserted(ErrorCodes::TypeMismatch,
str::stream() << "BSON field '" << path << "' is the wrong type '"
- << typeName(elementType)
- << "', expected type '"
- << typeName(type)
+ << typeName(elementType) << "', expected type '" << typeName(type)
<< "'");
}
@@ -93,10 +91,8 @@ bool IDLParserErrorContext::checkAndAssertBinDataTypeSlowPath(const BSONElement&
std::string path = getElementPath(element);
uasserted(ErrorCodes::TypeMismatch,
str::stream() << "BSON field '" << path << "' is the wrong bindData type '"
- << typeName(element.binDataType())
- << "', expected type '"
- << typeName(type)
- << "'");
+ << typeName(element.binDataType()) << "', expected type '"
+ << typeName(type) << "'");
}
return true;
@@ -117,9 +113,7 @@ bool IDLParserErrorContext::checkAndAssertTypes(const BSONElement& element,
std::string type_str = toCommaDelimitedList(types);
uasserted(ErrorCodes::TypeMismatch,
str::stream() << "BSON field '" << path << "' is the wrong type '"
- << typeName(element.type())
- << "', expected types '["
- << type_str
+ << typeName(element.type()) << "', expected types '[" << type_str
<< "']");
}
@@ -204,10 +198,8 @@ void IDLParserErrorContext::throwBadArrayFieldNumberSequence(std::uint32_t actua
std::string path = getElementPath(StringData());
uasserted(40423,
str::stream() << "BSON array field '" << path << "' has a non-sequential value '"
- << actualValue
- << "' for an array field name, expected value '"
- << expectedValue
- << "'.");
+ << actualValue << "' for an array field name, expected value '"
+ << expectedValue << "'.");
}
void IDLParserErrorContext::throwBadEnumValue(int enumValue) const {
diff --git a/src/mongo/idl/idl_parser.h b/src/mongo/idl/idl_parser.h
index 32a3f83b1af..70fdcd97f76 100644
--- a/src/mongo/idl/idl_parser.h
+++ b/src/mongo/idl/idl_parser.h
@@ -188,8 +188,8 @@ private:
bool checkAndAssertTypeSlowPath(const BSONElement& element, BSONType type) const;
/**
- * See comment on checkAndAssertBinDataType.
- */
+ * See comment on checkAndAssertBinDataType.
+ */
bool checkAndAssertBinDataTypeSlowPath(const BSONElement& element, BinDataType type) const;
private:
@@ -222,10 +222,7 @@ template <typename T>
void throwComparisonError(StringData fieldName, StringData op, T actualValue, T expectedValue) {
uasserted(51024,
str::stream() << "BSON field '" << fieldName << "' value must be " << op << " "
- << expectedValue
- << ", actual value '"
- << actualValue
- << "'");
+ << expectedValue << ", actual value '" << actualValue << "'");
}
diff --git a/src/mongo/idl/idl_test.cpp b/src/mongo/idl/idl_test.cpp
index f08ec698351..48bfe499823 100644
--- a/src/mongo/idl/idl_test.cpp
+++ b/src/mongo/idl/idl_test.cpp
@@ -100,8 +100,8 @@ void assertOpMsgEquals(const OpMsgRequest& left, const OpMsgRequest& right) {
}
/**
-* Validate two OpMsgRequests are the same including their DocumentSequences.
-*/
+ * Validate two OpMsgRequests are the same including their DocumentSequences.
+ */
void assertOpMsgEqualsExact(const OpMsgRequest& left, const OpMsgRequest& right) {
ASSERT_BSONOBJ_EQ(left.body, right.body);
@@ -766,11 +766,8 @@ TEST(IDLFieldTests, TestOptionalFields) {
template <typename TestT>
void TestWeakType(TestT test_value) {
IDLParserErrorContext ctxt("root");
- auto testDoc =
- BSON("field1" << test_value << "field2" << test_value << "field3" << test_value << "field4"
- << test_value
- << "field5"
- << test_value);
+ auto testDoc = BSON("field1" << test_value << "field2" << test_value << "field3" << test_value
+ << "field4" << test_value << "field5" << test_value);
auto testStruct = Optional_field::parse(ctxt, testDoc);
ASSERT_FALSE(testStruct.getField1().is_initialized());
@@ -860,11 +857,8 @@ TEST(IDLArrayTests, TestSimpleArrays) {
auto testDoc = BSON("field1" << BSON_ARRAY("Foo"
<< "Bar"
<< "???")
- << "field2"
- << BSON_ARRAY(1 << 2 << 3)
- << "field3"
- << BSON_ARRAY(1.2 << 3.4 << 5.6)
- << "field4"
+ << "field2" << BSON_ARRAY(1 << 2 << 3) << "field3"
+ << BSON_ARRAY(1.2 << 3.4 << 5.6) << "field4"
<< BSON_ARRAY(BSONBinData(array1, 3, BinDataGeneral)
<< BSONBinData(array2, 3, BinDataGeneral))
<< "field5"
@@ -927,12 +921,10 @@ TEST(IDLArrayTests, TestSimpleOptionalArrays) {
auto testDoc = BSON("field1" << BSON_ARRAY("Foo"
<< "Bar"
<< "???")
- << "field2"
- << BSON_ARRAY(1 << 2 << 3)
- << "field3"
+ << "field2" << BSON_ARRAY(1 << 2 << 3) << "field3"
<< BSON_ARRAY(1.2 << 3.4 << 5.6)
- );
+ );
auto testStruct = Optional_array_fields::parse(ctxt, testDoc);
assert_same_types<decltype(testStruct.getField1()),
@@ -1062,35 +1054,27 @@ TEST(IDLArrayTests, TestArraysOfComplexTypes) {
IDLParserErrorContext ctxt("root");
// Positive: Test document
- auto testDoc = BSON("field1" << BSON_ARRAY(1 << 2 << 3) << "field2" << BSON_ARRAY("a.b"
- << "c.d")
- << "field3"
- << BSON_ARRAY(1 << "2")
- << "field4"
- << BSON_ARRAY(BSONObj() << BSONObj())
- << "field5"
- << BSON_ARRAY(BSONObj() << BSONObj() << BSONObj())
- << "field6"
+ auto testDoc = BSON("field1" << BSON_ARRAY(1 << 2 << 3) << "field2"
+ << BSON_ARRAY("a.b"
+ << "c.d")
+ << "field3" << BSON_ARRAY(1 << "2") << "field4"
+ << BSON_ARRAY(BSONObj() << BSONObj()) << "field5"
+ << BSON_ARRAY(BSONObj() << BSONObj() << BSONObj()) << "field6"
<< BSON_ARRAY(BSON("value"
<< "hello")
<< BSON("value"
<< "world"))
- << "field1o"
- << BSON_ARRAY(1 << 2 << 3)
- << "field2o"
+ << "field1o" << BSON_ARRAY(1 << 2 << 3) << "field2o"
<< BSON_ARRAY("a.b"
<< "c.d")
- << "field3o"
- << BSON_ARRAY(1 << "2")
- << "field4o"
- << BSON_ARRAY(BSONObj() << BSONObj())
- << "field6o"
+ << "field3o" << BSON_ARRAY(1 << "2") << "field4o"
+ << BSON_ARRAY(BSONObj() << BSONObj()) << "field6o"
<< BSON_ARRAY(BSON("value"
<< "goodbye")
<< BSON("value"
<< "world"))
- );
+ );
auto testStruct = Complex_array_fields::parse(ctxt, testDoc);
assert_same_types<decltype(testStruct.getField1()), const std::vector<std::int64_t>&>();
@@ -1406,8 +1390,7 @@ TEST(IDLChainedType, TestChainedType) {
auto testDoc = BSON("field1"
<< "abc"
- << "field2"
- << 5);
+ << "field2" << 5);
auto testStruct = Chained_struct_only::parse(ctxt, testDoc);
@@ -1450,10 +1433,7 @@ TEST(IDLChainedType, TestExtraFields) {
auto testDoc = BSON("field1"
<< "abc"
- << "field2"
- << 5
- << "field3"
- << 123456);
+ << "field2" << 5 << "field3" << 123456);
auto testStruct = Chained_struct_only::parse(ctxt, testDoc);
ASSERT_EQUALS(testStruct.getChainedType().getField1(), "abc");
@@ -1467,10 +1447,7 @@ TEST(IDLChainedType, TestDuplicateFields) {
auto testDoc = BSON("field1"
<< "abc"
- << "field2"
- << 5
- << "field2"
- << 123456);
+ << "field2" << 5 << "field2" << 123456);
ASSERT_THROWS(Chained_struct_only::parse(ctxt, testDoc), AssertionException);
}
@@ -1480,8 +1457,9 @@ TEST(IDLChainedType, TestDuplicateFields) {
TEST(IDLChainedType, TestChainedStruct) {
IDLParserErrorContext ctxt("root");
- auto testDoc = BSON("anyField" << 123.456 << "objectField" << BSON("random"
- << "pair")
+ auto testDoc = BSON("anyField" << 123.456 << "objectField"
+ << BSON("random"
+ << "pair")
<< "field3"
<< "abc");
@@ -1511,13 +1489,10 @@ TEST(IDLChainedType, TestChainedStructWithExtraFields) {
{
auto testDoc = BSON("field3"
<< "abc"
- << "anyField"
- << 123.456
- << "objectField"
+ << "anyField" << 123.456 << "objectField"
<< BSON("random"
<< "pair")
- << "extraField"
- << 787);
+ << "extraField" << 787);
ASSERT_THROWS(Chained_struct_mixed::parse(ctxt, testDoc), AssertionException);
}
@@ -1526,13 +1501,10 @@ TEST(IDLChainedType, TestChainedStructWithExtraFields) {
{
auto testDoc = BSON("field3"
<< "abc"
- << "anyField"
- << 123.456
- << "objectField"
+ << "anyField" << 123.456 << "objectField"
<< BSON("random"
<< "pair")
- << "anyField"
- << 787);
+ << "anyField" << 787);
ASSERT_THROWS(Chained_struct_mixed::parse(ctxt, testDoc), AssertionException);
}
@@ -1542,9 +1514,7 @@ TEST(IDLChainedType, TestChainedStructWithExtraFields) {
<< "thing")
<< "field3"
<< "abc"
- << "anyField"
- << 123.456
- << "objectField"
+ << "anyField" << 123.456 << "objectField"
<< BSON("random"
<< "pair"));
ASSERT_THROWS(Chained_struct_mixed::parse(ctxt, testDoc), AssertionException);
@@ -1554,9 +1524,7 @@ TEST(IDLChainedType, TestChainedStructWithExtraFields) {
{
auto testDoc = BSON("field3"
<< "abc"
- << "anyField"
- << 123.456
- << "objectField"
+ << "anyField" << 123.456 << "objectField"
<< BSON("random"
<< "pair")
<< "field3"
@@ -1572,12 +1540,9 @@ TEST(IDLChainedType, TestChainedMixedStruct) {
auto testDoc = BSON("field1"
<< "abc"
- << "field2"
- << 5
- << "stringField"
+ << "field2" << 5 << "stringField"
<< "def"
- << "field3"
- << 456);
+ << "field3" << 456);
auto testStruct = Chained_struct_type_mixed::parse(ctxt, testDoc);
@@ -1718,9 +1683,7 @@ TEST(IDLCommand, TestConcatentateWithDb) {
IDLParserErrorContext ctxt("root");
auto testDoc = BSON(BasicConcatenateWithDbCommand::kCommandName << "coll1"
- << "field1"
- << 3
- << "field2"
+ << "field1" << 3 << "field2"
<< "five"
<< "$db"
<< "db");
@@ -1742,11 +1705,10 @@ TEST(IDLCommand, TestConcatentateWithDb) {
// Positive: Test we can serialize from nothing the same document except for $db
{
- auto testDocWithoutDb = BSON(BasicConcatenateWithDbCommand::kCommandName << "coll1"
- << "field1"
- << 3
- << "field2"
- << "five");
+ auto testDocWithoutDb =
+ BSON(BasicConcatenateWithDbCommand::kCommandName << "coll1"
+ << "field1" << 3 << "field2"
+ << "five");
BSONObjBuilder builder;
BasicConcatenateWithDbCommand one_new(NamespaceString("db.coll1"));
@@ -1791,11 +1753,10 @@ TEST(IDLCommand, TestConcatentateWithDbNegative) {
// Negative - duplicate namespace field
{
- auto testDoc = BSON("BasicConcatenateWithDbCommand" << 1 << "field1" << 3
- << "BasicConcatenateWithDbCommand"
- << 1
- << "field2"
- << "five");
+ auto testDoc =
+ BSON("BasicConcatenateWithDbCommand" << 1 << "field1" << 3
+ << "BasicConcatenateWithDbCommand" << 1 << "field2"
+ << "five");
ASSERT_THROWS(BasicConcatenateWithDbCommand::parse(ctxt, makeOMR(testDoc)),
AssertionException);
}
@@ -1838,13 +1799,12 @@ TEST(IDLCommand, TestConcatentateWithDbNegative) {
TEST(IDLCommand, TestConcatentateWithDbOrUUID_TestNSS) {
IDLParserErrorContext ctxt("root");
- auto testDoc = BSON(BasicConcatenateWithDbOrUUIDCommand::kCommandName << "coll1"
- << "field1"
- << 3
- << "field2"
- << "five"
- << "$db"
- << "db");
+ auto testDoc =
+ BSON(BasicConcatenateWithDbOrUUIDCommand::kCommandName << "coll1"
+ << "field1" << 3 << "field2"
+ << "five"
+ << "$db"
+ << "db");
auto testStruct = BasicConcatenateWithDbOrUUIDCommand::parse(ctxt, makeOMR(testDoc));
ASSERT_EQUALS(testStruct.getField1(), 3);
@@ -1863,11 +1823,10 @@ TEST(IDLCommand, TestConcatentateWithDbOrUUID_TestNSS) {
// Positive: Test we can serialize from nothing the same document except for $db
{
- auto testDocWithoutDb = BSON(BasicConcatenateWithDbOrUUIDCommand::kCommandName << "coll1"
- << "field1"
- << 3
- << "field2"
- << "five");
+ auto testDocWithoutDb =
+ BSON(BasicConcatenateWithDbOrUUIDCommand::kCommandName << "coll1"
+ << "field1" << 3 << "field2"
+ << "five");
BSONObjBuilder builder;
BasicConcatenateWithDbOrUUIDCommand one_new(NamespaceString("db.coll1"));
@@ -1921,9 +1880,9 @@ TEST(IDLCommand, TestConcatentateWithDbOrUUID_TestUUID) {
// Positive: Test we can serialize from nothing the same document except for $db
{
- auto testDocWithoutDb = BSON(
- BasicConcatenateWithDbOrUUIDCommand::kCommandName << uuid << "field1" << 3 << "field2"
- << "five");
+ auto testDocWithoutDb = BSON(BasicConcatenateWithDbOrUUIDCommand::kCommandName
+ << uuid << "field1" << 3 << "field2"
+ << "five");
BSONObjBuilder builder;
BasicConcatenateWithDbOrUUIDCommand one_new(NamespaceStringOrUUID("db", uuid));
@@ -1954,11 +1913,9 @@ TEST(IDLCommand, TestConcatentateWithDbOrUUIDNegative) {
// Negative - duplicate namespace field
{
auto testDoc =
- BSON("BasicConcatenateWithDbOrUUIDCommand" << 1 << "field1" << 3
- << "BasicConcatenateWithDbOrUUIDCommand"
- << 1
- << "field2"
- << "five");
+ BSON("BasicConcatenateWithDbOrUUIDCommand"
+ << 1 << "field1" << 3 << "BasicConcatenateWithDbOrUUIDCommand" << 1 << "field2"
+ << "five");
ASSERT_THROWS(BasicConcatenateWithDbOrUUIDCommand::parse(ctxt, makeOMR(testDoc)),
AssertionException);
}
@@ -2040,9 +1997,9 @@ TEST(IDLCommand, TestIgnoredNegative) {
// Negative - duplicate namespace field
{
- auto testDoc = BSON(
- "BasicIgnoredCommand" << 1 << "field1" << 3 << "BasicIgnoredCommand" << 1 << "field2"
- << "five");
+ auto testDoc = BSON("BasicIgnoredCommand" << 1 << "field1" << 3 << "BasicIgnoredCommand"
+ << 1 << "field2"
+ << "five");
ASSERT_THROWS(BasicIgnoredCommand::parse(ctxt, makeOMR(testDoc)), AssertionException);
}
@@ -2067,9 +2024,7 @@ TEST(IDLDocSequence, TestBasic) {
auto testTempDoc = BSON("DocSequenceCommand"
<< "coll1"
- << "field1"
- << 3
- << "field2"
+ << "field1" << 3 << "field2"
<< "five"
<< "$db"
<< "db"
@@ -2078,8 +2033,7 @@ TEST(IDLDocSequence, TestBasic) {
<< "hello")
<< BSON("value"
<< "world"))
- << "objects"
- << BSON_ARRAY(BSON("foo" << 1)));
+ << "objects" << BSON_ARRAY(BSON("foo" << 1)));
OpMsgRequest request;
request.body = testTempDoc;
@@ -2145,15 +2099,12 @@ TEST(IDLDocSequence, TestMissingDB) {
auto testTempDoc = BSON("DocSequenceCommand"
<< "coll1"
- << "field1"
- << 3
- << "field2"
+ << "field1" << 3 << "field2"
<< "five"
<< "structs"
<< BSON_ARRAY(BSON("value"
<< "hello"))
- << "objects"
- << BSON_ARRAY(BSON("foo" << 1)));
+ << "objects" << BSON_ARRAY(BSON("foo" << 1)));
OpMsgRequest request;
request.body = testTempDoc;
@@ -2167,9 +2118,7 @@ void TestDocSequence(StringData name) {
IDLParserErrorContext ctxt("root");
auto testTempDoc = BSON(name << "coll1"
- << "field1"
- << 3
- << "field2"
+ << "field1" << 3 << "field2"
<< "five");
OpMsgRequest request = OpMsgRequest::fromDBAndBody("db", testTempDoc);
@@ -2208,9 +2157,7 @@ void TestBadDocSequences(StringData name, bool extraFieldAllowed) {
IDLParserErrorContext ctxt("root");
auto testTempDoc = BSON(name << "coll1"
- << "field1"
- << 3
- << "field2"
+ << "field1" << 3 << "field2"
<< "five");
// Negative: Duplicate fields in doc sequence
@@ -2279,17 +2226,14 @@ void TestDuplicateDocSequences(StringData name) {
// Negative: Duplicate fields in doc sequence and body
{
auto testTempDoc = BSON(name << "coll1"
- << "field1"
- << 3
- << "field2"
+ << "field1" << 3 << "field2"
<< "five"
<< "structs"
<< BSON_ARRAY(BSON("value"
<< "hello")
<< BSON("value"
<< "world"))
- << "objects"
- << BSON_ARRAY(BSON("foo" << 1)));
+ << "objects" << BSON_ARRAY(BSON("foo" << 1)));
OpMsgRequest request = OpMsgRequest::fromDBAndBody("db", testTempDoc);
request.sequences.push_back({"structs",
@@ -2304,17 +2248,14 @@ void TestDuplicateDocSequences(StringData name) {
// Negative: Duplicate fields in doc sequence and body
{
auto testTempDoc = BSON(name << "coll1"
- << "field1"
- << 3
- << "field2"
+ << "field1" << 3 << "field2"
<< "five"
<< "structs"
<< BSON_ARRAY(BSON("value"
<< "hello")
<< BSON("value"
<< "world"))
- << "objects"
- << BSON_ARRAY(BSON("foo" << 1)));
+ << "objects" << BSON_ARRAY(BSON("foo" << 1)));
OpMsgRequest request = OpMsgRequest::fromDBAndBody("db", testTempDoc);
request.sequences.push_back({"objects", {BSON("foo" << 1)}});
@@ -2337,17 +2278,14 @@ TEST(IDLDocSequence, TestEmptySequence) {
{
auto testTempDoc = BSON("DocSequenceCommand"
<< "coll1"
- << "field1"
- << 3
- << "field2"
+ << "field1" << 3 << "field2"
<< "five"
<< "structs"
<< BSON_ARRAY(BSON("value"
<< "hello")
<< BSON("value"
<< "world"))
- << "objects"
- << BSON_ARRAY(BSON("foo" << 1)));
+ << "objects" << BSON_ARRAY(BSON("foo" << 1)));
OpMsgRequest request = OpMsgRequest::fromDBAndBody("db", testTempDoc);
request.sequences.push_back({"structs", {}});
@@ -2359,12 +2297,9 @@ TEST(IDLDocSequence, TestEmptySequence) {
{
auto testTempDoc = BSON("DocSequenceCommand"
<< "coll1"
- << "field1"
- << 3
- << "field2"
+ << "field1" << 3 << "field2"
<< "five"
- << "objects"
- << BSON_ARRAY(BSON("foo" << 1)));
+ << "objects" << BSON_ARRAY(BSON("foo" << 1)));
OpMsgRequest request = OpMsgRequest::fromDBAndBody("db", testTempDoc);
request.sequences.push_back({"structs", {}});
@@ -2396,19 +2331,14 @@ TEST(IDLDocSequence, TestWellKnownFieldsAreIgnored) {
for (auto knownField : knownFields) {
auto testTempDoc = BSON("DocSequenceCommand"
<< "coll1"
- << "field1"
- << 3
- << "field2"
- << "five"
- << knownField
- << "extra"
+ << "field1" << 3 << "field2"
+ << "five" << knownField << "extra"
<< "structs"
<< BSON_ARRAY(BSON("value"
<< "hello")
<< BSON("value"
<< "world"))
- << "objects"
- << BSON_ARRAY(BSON("foo" << 1)));
+ << "objects" << BSON_ARRAY(BSON("foo" << 1)));
OpMsgRequest request = OpMsgRequest::fromDBAndBody("db", testTempDoc);
@@ -2448,21 +2378,16 @@ TEST(IDLDocSequence, TestWellKnownFieldsPassthrough) {
for (auto knownField : knownFields) {
auto testTempDoc = BSON("DocSequenceCommand"
<< "coll1"
- << "field1"
- << 3
- << "field2"
+ << "field1" << 3 << "field2"
<< "five"
<< "$db"
- << "db"
- << knownField
- << "extra"
+ << "db" << knownField << "extra"
<< "structs"
<< BSON_ARRAY(BSON("value"
<< "hello")
<< BSON("value"
<< "world"))
- << "objects"
- << BSON_ARRAY(BSON("foo" << 1)));
+ << "objects" << BSON_ARRAY(BSON("foo" << 1)));
OpMsgRequest request;
request.body = testTempDoc;
@@ -2482,9 +2407,7 @@ TEST(IDLDocSequence, TestNonStrict) {
{
auto testTempDoc = BSON("DocSequenceCommandNonStrict"
<< "coll1"
- << "field1"
- << 3
- << "field2"
+ << "field1" << 3 << "field2"
<< "five");
OpMsgRequest request = OpMsgRequest::fromDBAndBody("db", testTempDoc);
@@ -2504,12 +2427,9 @@ TEST(IDLDocSequence, TestNonStrict) {
{
auto testTempDoc = BSON("DocSequenceCommandNonStrict"
<< "coll1"
- << "field1"
- << 3
- << "field2"
+ << "field1" << 3 << "field2"
<< "five"
- << "extra"
- << 1);
+ << "extra" << 1);
OpMsgRequest request = OpMsgRequest::fromDBAndBody("db", testTempDoc);
request.sequences.push_back({"structs",
@@ -2531,19 +2451,14 @@ TEST(IDLCommand, TestKnownFieldDuplicate) {
auto testPassthrough = BSON("$db"
<< "foo"
- << "maxTimeMS"
- << 6
- << "$client"
+ << "maxTimeMS" << 6 << "$client"
<< "foo");
auto testDoc = BSON("KnownFieldCommand"
<< "coll1"
<< "$db"
<< "db"
- << "field1"
- << 28
- << "maxTimeMS"
- << 42);
+ << "field1" << 28 << "maxTimeMS" << 42);
auto testStruct = KnownFieldCommand::parse(ctxt, makeOMR(testDoc));
ASSERT_EQUALS(28, testStruct.getField1());
@@ -2553,11 +2468,7 @@ TEST(IDLCommand, TestKnownFieldDuplicate) {
auto expectedOpMsgDoc = BSON("KnownFieldCommand"
<< "coll1"
- << "field1"
- << 28
- << "maxTimeMS"
- << 42
- << "$db"
+ << "field1" << 28 << "maxTimeMS" << 42 << "$db"
<< "db"
<< "$client"
@@ -2569,11 +2480,7 @@ TEST(IDLCommand, TestKnownFieldDuplicate) {
auto expectedBSONDoc = BSON("KnownFieldCommand"
<< "coll1"
- << "field1"
- << 28
- << "maxTimeMS"
- << 42
- << "$db"
+ << "field1" << 28 << "maxTimeMS" << 42 << "$db"
<< "foo"
<< "$client"
@@ -2664,14 +2571,9 @@ TEST(IDLValidatedField, Int_basic_ranges) {
std::int32_t byte_range,
std::int32_t int_range) {
IDLParserErrorContext ctxt("root");
- auto doc =
- BSON("positive_int" << pos << "negative_int" << neg << "non_negative_int" << nonneg
- << "non_positive_int"
- << nonpos
- << "byte_range_int"
- << byte_range
- << "range_int"
- << int_range);
+ auto doc = BSON("positive_int" << pos << "negative_int" << neg << "non_negative_int"
+ << nonneg << "non_positive_int" << nonpos << "byte_range_int"
+ << byte_range << "range_int" << int_range);
auto obj = Int_basic_ranges::parse(ctxt, doc);
ASSERT_EQUALS(obj.getPositive_int(), pos);
ASSERT_EQUALS(obj.getNegative_int(), neg);
@@ -2689,14 +2591,9 @@ TEST(IDLValidatedField, Int_basic_ranges) {
std::int32_t byte_range,
std::int32_t int_range) {
IDLParserErrorContext ctxt("root");
- auto doc =
- BSON("positive_int" << pos << "negative_int" << neg << "non_negative_int" << nonneg
- << "non_positive_int"
- << nonpos
- << "byte_range_int"
- << byte_range
- << "range_int"
- << int_range);
+ auto doc = BSON("positive_int" << pos << "negative_int" << neg << "non_negative_int"
+ << nonneg << "non_positive_int" << nonpos << "byte_range_int"
+ << byte_range << "range_int" << int_range);
ASSERT_THROWS(Int_basic_ranges::parse(ctxt, doc), AssertionException);
};
@@ -2744,13 +2641,9 @@ TEST(IDLValidatedField, Double_basic_ranges) {
const auto tryPass =
[](double pos, double neg, double nonneg, double nonpos, double double_range) {
IDLParserErrorContext ctxt("root");
- auto doc =
- BSON("positive_double" << pos << "negative_double" << neg << "non_negative_double"
- << nonneg
- << "non_positive_double"
- << nonpos
- << "range_double"
- << double_range);
+ auto doc = BSON("positive_double"
+ << pos << "negative_double" << neg << "non_negative_double" << nonneg
+ << "non_positive_double" << nonpos << "range_double" << double_range);
auto obj = Double_basic_ranges::parse(ctxt, doc);
ASSERT_EQUALS(obj.getPositive_double(), pos);
ASSERT_EQUALS(obj.getNegative_double(), neg);
@@ -2763,13 +2656,9 @@ TEST(IDLValidatedField, Double_basic_ranges) {
const auto tryFail =
[](double pos, double neg, double nonneg, double nonpos, double double_range) {
IDLParserErrorContext ctxt("root");
- auto doc =
- BSON("positive_double" << pos << "negative_double" << neg << "non_negative_double"
- << nonneg
- << "non_positive_double"
- << nonpos
- << "range_double"
- << double_range);
+ auto doc = BSON("positive_double"
+ << pos << "negative_double" << neg << "non_negative_double" << nonneg
+ << "non_positive_double" << nonpos << "range_double" << double_range);
ASSERT_THROWS(Double_basic_ranges::parse(ctxt, doc), AssertionException);
};
@@ -2807,8 +2696,7 @@ TEST(IDLValidatedField, Callback_validators) {
[](std::int32_t int_even, double double_nearly_int, StringData string_starts_with_x) {
IDLParserErrorContext ctxt("root");
auto doc = BSON("int_even" << int_even << "double_nearly_int" << double_nearly_int
- << "string_starts_with_x"
- << string_starts_with_x);
+ << "string_starts_with_x" << string_starts_with_x);
auto obj = Callback_validators::parse(ctxt, doc);
ASSERT_EQUALS(obj.getInt_even(), int_even);
ASSERT_EQUALS(obj.getDouble_nearly_int(), double_nearly_int);
@@ -2820,8 +2708,7 @@ TEST(IDLValidatedField, Callback_validators) {
[](std::int32_t int_even, double double_nearly_int, StringData string_starts_with_x) {
IDLParserErrorContext ctxt("root");
auto doc = BSON("int_even" << int_even << "double_nearly_int" << double_nearly_int
- << "string_starts_with_x"
- << string_starts_with_x);
+ << "string_starts_with_x" << string_starts_with_x);
ASSERT_THROWS(Callback_validators::parse(ctxt, doc), AssertionException);
};
@@ -2844,9 +2731,7 @@ TEST(IDLTypeCommand, TestString) {
IDLParserErrorContext ctxt("root");
auto testDoc = BSON(CommandTypeStringCommand::kCommandName << "foo"
- << "field1"
- << 3
- << "$db"
+ << "field1" << 3 << "$db"
<< "db");
auto testStruct = CommandTypeStringCommand::parse(ctxt, makeOMR(testDoc));
@@ -2866,8 +2751,7 @@ TEST(IDLTypeCommand, TestString) {
// Positive: Test we can serialize from nothing the same document except for $db
{
auto testDocWithoutDb = BSON(CommandTypeStringCommand::kCommandName << "foo"
- << "field1"
- << 3);
+ << "field1" << 3);
BSONObjBuilder builder;
CommandTypeStringCommand one_new("foo");
@@ -3007,9 +2891,7 @@ TEST(IDLTypeCommand, TestUnderscoreCommand) {
IDLParserErrorContext ctxt("root");
auto testDoc = BSON(WellNamedCommand::kCommandName << "foo"
- << "field1"
- << 3
- << "$db"
+ << "field1" << 3 << "$db"
<< "db");
auto testStruct = WellNamedCommand::parse(ctxt, makeOMR(testDoc));
@@ -3029,8 +2911,7 @@ TEST(IDLTypeCommand, TestUnderscoreCommand) {
// Positive: Test we can serialize from nothing the same document except for $db
{
auto testDocWithoutDb = BSON(WellNamedCommand::kCommandName << "foo"
- << "field1"
- << 3);
+ << "field1" << 3);
BSONObjBuilder builder;
WellNamedCommand one_new("foo");
diff --git a/src/mongo/idl/server_parameter_specialized_test.cpp b/src/mongo/idl/server_parameter_specialized_test.cpp
index 7bf9cdb6bc6..52a7e8af8b0 100644
--- a/src/mongo/idl/server_parameter_specialized_test.cpp
+++ b/src/mongo/idl/server_parameter_specialized_test.cpp
@@ -242,24 +242,20 @@ TEST(SpecializedServerParameter, multiValue) {
ASSERT_APPENDED_OBJECT(edsp,
BSON("value"
<< "start value"
- << "flag"
- << true));
+ << "flag" << true));
ASSERT_OK(edsp->setFromString("second value"));
ASSERT_APPENDED_OBJECT(edsp,
BSON("value"
<< "second value"
- << "flag"
- << false));
+ << "flag" << false));
ASSERT_OK(edsp->set(BSON("" << BSON("value"
<< "third value"
- << "flag"
- << true))
+ << "flag" << true))
.firstElement()));
ASSERT_APPENDED_OBJECT(edsp,
BSON("value"
<< "third value"
- << "flag"
- << true));
+ << "flag" << true));
}
// specializedWithCtorAndValue
diff --git a/src/mongo/idl/server_parameter_with_storage.h b/src/mongo/idl/server_parameter_with_storage.h
index 30d1d4abc7d..480983f4ad2 100644
--- a/src/mongo/idl/server_parameter_with_storage.h
+++ b/src/mongo/idl/server_parameter_with_storage.h
@@ -294,15 +294,12 @@ public:
*/
template <class predicate>
void addBound(const element_type& bound) {
- addValidator([ bound, spname = name() ](const element_type& value) {
+ addValidator([bound, spname = name()](const element_type& value) {
if (!predicate::evaluate(value, bound)) {
return Status(ErrorCodes::BadValue,
- str::stream() << "Invalid value for parameter " << spname << ": "
- << value
- << " is not "
- << predicate::description
- << " "
- << bound);
+ str::stream()
+ << "Invalid value for parameter " << spname << ": " << value
+ << " is not " << predicate::description << " " << bound);
}
return Status::OK();
});