The following issues were found
src/mongo/db/update/pop_node_test.cpp
1 issues
Line: 55
ASSERT_FALSE(popNode.popFromFront());
}
TEST(PopNodeTest, InitSucceedsNegativeOne) {
auto update = fromjson("{$pop: {a: -1}}");
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
PopNode popNode;
ASSERT_OK(popNode.init(update["$pop"]["a"], expCtx));
ASSERT_TRUE(popNode.popFromFront());
Reported by Cppcheck.
src/mongo/db/update/pull_node_test.cpp
1 issues
Line: 50
using mongo::mutablebson::countChildren;
using mongo::mutablebson::Element;
TEST(PullNodeTest, InitWithBadMatchExpressionFails) {
auto update = fromjson("{$pull: {a: {b: {$foo: 1}}}}");
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
PullNode node;
auto status = node.init(update["$pull"]["a"], expCtx);
ASSERT_NOT_OK(status);
Reported by Cppcheck.
src/mongo/db/update/pullall_node_test.cpp
1 issues
Line: 50
using mongo::mutablebson::countChildren;
using mongo::mutablebson::Element;
TEST(PullAllNodeTest, InitWithIntFails) {
auto update = fromjson("{$pullAll: {a: 1}}");
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
PullAllNode node;
auto status = node.init(update["$pullAll"]["a"], expCtx);
ASSERT_NOT_OK(status);
Reported by Cppcheck.
src/mongo/db/update/push_node_test.cpp
1 issues
Line: 50
using mongo::mutablebson::countChildren;
using mongo::mutablebson::Element;
TEST(PushNodeTest, EachClauseWithNonArrayObjectFails) {
auto update = fromjson("{$push: {x: {$each: {'0': 1}}}}");
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
PushNode node;
auto status = node.init(update["$push"]["x"], expCtx);
ASSERT_NOT_OK(status);
Reported by Cppcheck.
src/mongo/db/update/push_sorter_test.cpp
1 issues
Line: 83
size_t _size;
};
TEST_F(ObjectArray, NormalOrder) {
const CollatorInterface* collator = nullptr;
addObj(fromjson("{b:1, a:1}"));
addObj(fromjson("{a:3, b:2}"));
addObj(fromjson("{b:3, a:2}"));
Reported by Cppcheck.
src/mongo/db/update/rename_node_test.cpp
1 issues
Line: 50
using mongo::mutablebson::countChildren;
using mongo::mutablebson::Element;
TEST(RenameNodeTest, PositionalNotAllowedInFromField) {
auto update = fromjson("{$rename: {'a.$': 'b'}}");
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
RenameNode node;
Status status = node.init(update["$rename"]["a.$"], expCtx);
ASSERT_NOT_OK(status);
Reported by Cppcheck.
src/mongo/db/update/set_node_test.cpp
1 issues
Line: 50
using mongo::mutablebson::countChildren;
using mongo::mutablebson::Element;
DEATH_TEST_REGEX(SetNodeTest, InitFailsForEmptyElement, R"#(Invariant failure.*modExpr.ok\(\))#") {
auto update = fromjson("{$set: {}}");
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
SetNode node;
node.init(update["$set"].embeddedObject().firstElement(), expCtx).transitional_ignore();
}
Reported by Cppcheck.
src/mongo/db/update/unset_node_test.cpp
1 issues
Line: 50
using mongo::mutablebson::countChildren;
using mongo::mutablebson::Element;
DEATH_TEST_REGEX(UnsetNodeTest,
InitFailsForEmptyElement,
R"#(Invariant failure.*modExpr.ok\(\))#") {
auto update = fromjson("{$unset: {}}");
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
UnsetNode node;
Reported by Cppcheck.
src/mongo/db/update/update_array_node_test.cpp
1 issues
Line: 52
using mongo::mutablebson::Element;
using unittest::assertGet;
TEST_F(UpdateArrayNodeTest, ApplyCreatePathFails) {
auto update = fromjson("{$set: {'a.b.$[i]': 0}}");
auto arrayFilter = fromjson("{i: 0}");
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
std::map<StringData, std::unique_ptr<ExpressionWithPlaceholder>> arrayFilters;
auto parsedFilter = assertGet(MatchExpressionParser::parse(arrayFilter, expCtx));
Reported by Cppcheck.
src/mongo/db/update/update_driver_test.cpp
1 issues
Line: 69
return write_ops::UpdateModification::parseFromClassicUpdate(bson);
}
TEST(Parse, Normal) {
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
UpdateDriver driver(expCtx);
std::map<StringData, std::unique_ptr<ExpressionWithPlaceholder>> arrayFilters;
ASSERT_DOES_NOT_THROW(driver.parse(makeUpdateMod(fromjson("{$set:{a:1}}")), arrayFilters));
ASSERT_FALSE(driver.type() == UpdateDriver::UpdateType::kReplacement);
Reported by Cppcheck.