diff options
author | Ted Tuckman <ted.tuckman@mongodb.com> | 2020-07-10 10:19:26 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-10-02 14:00:45 +0000 |
commit | 0348620630f3dd86214676e7e9566a6aa6e6be5c (patch) | |
tree | a1b84365ffc80bb73c2df02c18029d6f147e147b /src/mongo/db/pipeline/expression_test.cpp | |
parent | 45637f4d481c8badd6d5a2d95dcb8ae947c78c92 (diff) | |
download | mongo-0348620630f3dd86214676e7e9566a6aa6e6be5c.tar.gz |
SERVER-25893 Make it easier to construct a Value from a Vector
Diffstat (limited to 'src/mongo/db/pipeline/expression_test.cpp')
-rw-r--r-- | src/mongo/db/pipeline/expression_test.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/mongo/db/pipeline/expression_test.cpp b/src/mongo/db/pipeline/expression_test.cpp index e1eeb44d3d2..c5deffd22e8 100644 --- a/src/mongo/db/pipeline/expression_test.cpp +++ b/src/mongo/db/pipeline/expression_test.cpp @@ -67,7 +67,7 @@ static Value evaluateExpression(const string& expressionName, const vector<ImplicitValue>& operands) { auto expCtx = ExpressionContextForTest{}; VariablesParseState vps = expCtx.variablesParseState; - const BSONObj obj = BSON(expressionName << ImplicitValue::convertToValue(operands)); + const BSONObj obj = BSON(expressionName << Value(ImplicitValue::convertToValues(operands))); auto expression = Expression::parseExpression(&expCtx, obj, vps); Value result = expression->evaluate({}, &expCtx.variables); return result; @@ -80,14 +80,14 @@ static Value evaluateExpression(const string& expressionName, */ static void assertExpectedResults( const string& expression, - initializer_list<pair<vector<ImplicitValue>, ImplicitValue>> operations) { + initializer_list<pair<initializer_list<ImplicitValue>, ImplicitValue>> operations) { for (auto&& op : operations) { try { Value result = evaluateExpression(expression, op.first); ASSERT_VALUE_EQ(op.second, result); ASSERT_EQUALS(op.second.getType(), result.getType()); } catch (...) { - LOGV2(24188, "failed", "argument"_attr = ImplicitValue::convertToValue(op.first)); + LOGV2(24188, "failed", "argument"_attr = ImplicitValue::convertToValues(op.first)); throw; } } @@ -152,7 +152,7 @@ TEST(ExpressionArrayToObjectTest, KVFormatSimple) { << BSON("k" << "key2" << "v" << 3)))}, - {Value(BSON("key1" << 2 << "key2" << 3))}}}); + Value(BSON("key1" << 2 << "key2" << 3))}}); } TEST(ExpressionArrayToObjectTest, KVFormatWithDuplicates) { @@ -163,19 +163,19 @@ TEST(ExpressionArrayToObjectTest, KVFormatWithDuplicates) { << BSON("k" << "hi" << "v" << 3)))}, - {Value(BSON("hi" << 3))}}}); + Value(BSON("hi" << 3))}}); } TEST(ExpressionArrayToObjectTest, ListFormatSimple) { assertExpectedResults("$arrayToObject", {{{Value(BSON_ARRAY(BSON_ARRAY("key1" << 2) << BSON_ARRAY("key2" << 3)))}, - {Value(BSON("key1" << 2 << "key2" << 3))}}}); + Value(BSON("key1" << 2 << "key2" << 3))}}); } TEST(ExpressionArrayToObjectTest, ListFormWithDuplicates) { assertExpectedResults("$arrayToObject", {{{Value(BSON_ARRAY(BSON_ARRAY("key1" << 2) << BSON_ARRAY("key1" << 3)))}, - {Value(BSON("key1" << 3))}}}); + Value(BSON("key1" << 3))}}); } /* ------------------------ ExpressionRange --------------------------- */ @@ -2103,7 +2103,7 @@ TEST(BuiltinRemoveVariableTest, RemoveSerializesCorrectlyAfterOptimization) { namespace ExpressionMergeObjects { TEST(ExpressionMergeObjects, MergingWithSingleObjectShouldLeaveUnchanged) { - assertExpectedResults("$mergeObjects", {{{}, {Document({})}}}); + assertExpectedResults("$mergeObjects", {{{}, Document({})}}); auto doc = Document({{"a", 1}, {"b", 1}}); assertExpectedResults("$mergeObjects", {{{doc}, doc}}); |