summaryrefslogtreecommitdiff
path: root/src/mongo/rpc/command_request_builder_test.cpp
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2015-06-20 00:22:50 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2015-06-20 10:56:02 -0400
commit9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch)
tree3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/rpc/command_request_builder_test.cpp
parent01965cf52bce6976637ecb8f4a622aeb05ab256a (diff)
downloadmongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/rpc/command_request_builder_test.cpp')
-rw-r--r--src/mongo/rpc/command_request_builder_test.cpp79
1 files changed, 39 insertions, 40 deletions
diff --git a/src/mongo/rpc/command_request_builder_test.cpp b/src/mongo/rpc/command_request_builder_test.cpp
index 10a4f2d8795..cdfbc9d01a9 100644
--- a/src/mongo/rpc/command_request_builder_test.cpp
+++ b/src/mongo/rpc/command_request_builder_test.cpp
@@ -36,57 +36,56 @@
namespace {
- using namespace mongo;
+using namespace mongo;
- TEST(RequestBuilder, RoundTrip) {
+TEST(RequestBuilder, RoundTrip) {
+ auto databaseName = "barbaz";
+ auto commandName = "foobar";
- auto databaseName = "barbaz";
- auto commandName = "foobar";
+ BSONObjBuilder metadataBob{};
+ metadataBob.append("foo", "bar");
+ auto metadata = metadataBob.done();
- BSONObjBuilder metadataBob{};
- metadataBob.append("foo", "bar");
- auto metadata = metadataBob.done();
+ BSONObjBuilder commandArgsBob{};
+ commandArgsBob.append("bar", "baz");
+ auto commandArgs = commandArgsBob.done();
- BSONObjBuilder commandArgsBob{};
- commandArgsBob.append("bar", "baz");
- auto commandArgs = commandArgsBob.done();
+ BSONObjBuilder inputDoc1Bob{};
+ inputDoc1Bob.append("z", "t");
+ auto inputDoc1 = inputDoc1Bob.done();
- BSONObjBuilder inputDoc1Bob{};
- inputDoc1Bob.append("z", "t");
- auto inputDoc1 = inputDoc1Bob.done();
+ BSONObjBuilder inputDoc2Bob{};
+ inputDoc2Bob.append("h", "j");
+ auto inputDoc2 = inputDoc2Bob.done();
- BSONObjBuilder inputDoc2Bob{};
- inputDoc2Bob.append("h", "j");
- auto inputDoc2 = inputDoc2Bob.done();
+ BSONObjBuilder inputDoc3Bob{};
+ inputDoc3Bob.append("g", "p");
+ auto inputDoc3 = inputDoc3Bob.done();
- BSONObjBuilder inputDoc3Bob{};
- inputDoc3Bob.append("g", "p");
- auto inputDoc3 = inputDoc3Bob.done();
+ BufBuilder inputDocs;
+ inputDoc1.appendSelfToBufBuilder(inputDocs);
+ inputDoc2.appendSelfToBufBuilder(inputDocs);
+ inputDoc3.appendSelfToBufBuilder(inputDocs);
- BufBuilder inputDocs;
- inputDoc1.appendSelfToBufBuilder(inputDocs);
- inputDoc2.appendSelfToBufBuilder(inputDocs);
- inputDoc3.appendSelfToBufBuilder(inputDocs);
+ rpc::DocumentRange inputDocRange{inputDocs.buf(), inputDocs.buf() + inputDocs.len()};
- rpc::DocumentRange inputDocRange{inputDocs.buf(), inputDocs.buf() + inputDocs.len()};
+ rpc::CommandRequestBuilder r;
- rpc::CommandRequestBuilder r;
+ auto msg = r.setDatabase(databaseName)
+ .setCommandName(commandName)
+ .setMetadata(metadata)
+ .setCommandArgs(commandArgs)
+ .addInputDocs(inputDocRange)
+ .done();
- auto msg = r.setDatabase(databaseName)
- .setCommandName(commandName)
- .setMetadata(metadata)
- .setCommandArgs(commandArgs)
- .addInputDocs(inputDocRange)
- .done();
+ rpc::CommandRequest parsed(msg.get());
- rpc::CommandRequest parsed(msg.get());
-
- ASSERT_EQUALS(parsed.getDatabase(), databaseName);
- ASSERT_EQUALS(parsed.getCommandName(), commandName);
- ASSERT_EQUALS(parsed.getMetadata(), metadata);
- ASSERT_EQUALS(parsed.getCommandArgs(), commandArgs);
- // need ostream overloads for ASSERT_EQUALS
- ASSERT_TRUE(parsed.getInputDocs() == inputDocRange);
- }
+ ASSERT_EQUALS(parsed.getDatabase(), databaseName);
+ ASSERT_EQUALS(parsed.getCommandName(), commandName);
+ ASSERT_EQUALS(parsed.getMetadata(), metadata);
+ ASSERT_EQUALS(parsed.getCommandArgs(), commandArgs);
+ // need ostream overloads for ASSERT_EQUALS
+ ASSERT_TRUE(parsed.getInputDocs() == inputDocRange);
+}
} // namespace