diff options
Diffstat (limited to 'src/mongo/db/pipeline/expression_test.cpp')
| -rw-r--r-- | src/mongo/db/pipeline/expression_test.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/mongo/db/pipeline/expression_test.cpp b/src/mongo/db/pipeline/expression_test.cpp index 743f46ee6cd..8ff42966922 100644 --- a/src/mongo/db/pipeline/expression_test.cpp +++ b/src/mongo/db/pipeline/expression_test.cpp @@ -1602,11 +1602,10 @@ boost::intrusive_ptr<Expression> parseObject(BSONObj specification) { TEST(ParseObject, ShouldAcceptEmptyObject) { auto resultExpression = parseObject(BSONObj()); - // Should return an empty ExpressionObject. - auto resultObject = dynamic_cast<ExpressionObject*>(resultExpression.get()); + // Should return an empty object. + auto resultObject = dynamic_cast<ExpressionConstant*>(resultExpression.get()); ASSERT_TRUE(resultObject); - - ASSERT_EQ(resultObject->getChildExpressions().size(), 0UL); + ASSERT_VALUE_EQ(resultObject->getValue(), Value(Document{})); } TEST(ParseObject, ShouldRecognizeKnownExpression) { @@ -5126,6 +5125,13 @@ TEST(ExpressionParseParenthesisExpressionObjTest, SingleExprSimplification) { ASSERT_EQ(expr->serialize().toString(), "[{$const: 123}]"); } +TEST(ExpressionParseParenthesisExpressionObjTest, EmptyObject) { + auto expCtx = ExpressionContextForTest{}; + auto specObject = fromjson("{$expr: {}}"); + auto expr = Expression::parseObject(&expCtx, specObject, expCtx.variablesParseState); + ASSERT_EQ(expr->serialize().toString(), "{$const: {}}"); +} + /** * Test case for round-trip conversion of random double using $convert. * |
