The following issues were found
src/mongo/db/matcher/schema/object_keywords_test.cpp
1 issues
Line: 49
ASSERT_EQ(result.getStatus(), ErrorCodes::TypeMismatch);
}
TEST(JSONSchemaObjectKeywordTest, FailsToParseNicelyIfTypeIsKnownUnsupportedAlias) {
BSONObj schema = fromjson("{type: 'integer'}");
auto result = JSONSchemaParser::parse(new ExpressionContextForTest(), schema);
ASSERT_STRING_CONTAINS(result.getStatus().reason(),
"$jsonSchema type 'integer' is not currently supported");
}
Reported by Cppcheck.
src/mongo/db/matcher/schema/scalar_keywords_test.cpp
1 issues
Line: 53
"0}}, {num: {$_internalSchemaType: ['number']}}]}]}"));
}
TEST(JSONSchemaParserScalarTest, MaximumTranslatesCorrectlyWithBsonTypeLong) {
BSONObj schema =
fromjson("{properties: {num: {bsonType: 'long', maximum: 0}}, type: 'object'}");
auto result = JSONSchemaParser::parse(new ExpressionContextForTest(), schema);
ASSERT_OK(result.getStatus());
auto optimizedResult = MatchExpression::optimize(std::move(result.getValue()));
Reported by Cppcheck.
src/mongo/db/mirroring_sampler_test.cpp
1 issues
Line: 43
MirroringSampler::getMirroringTargets(dummyHello, -1);
}
DEATH_TEST(MirroringSamplerTest, ValidateLargeRatio, "invariant") {
auto dummyHello = std::make_shared<mongo::repl::HelloResponse>();
MirroringSampler::getMirroringTargets(dummyHello, 1.1);
}
TEST(MirroringSamplerTest, ValidateMissingHello) {
Reported by Cppcheck.
src/mongo/db/multi_key_path_tracker_test.cpp
1 issues
Line: 55
ASSERT(match);
}
TEST(MultikeyPathTracker, TestMergeMultikeyPaths) {
// Suppose the index key is {"a.c": 1, "a.b": 1, "c.d.b.e": 1}.
MultikeyPaths mutablePaths = {{}, {}, {}};
{
// `foundPaths` finds `a` to be multikey.
MultikeyPaths foundPaths = {{0}, {0}, {}};
Reported by Cppcheck.
src/mongo/db/namespace_string_test.cpp
1 issues
Line: 49
ASSERT(NamespaceString::oplog("local.oplog.$foo"));
}
TEST(NamespaceStringTest, DatabaseValidNames) {
ASSERT(NamespaceString::validDBName("foo", NamespaceString::DollarInDbNameBehavior::Allow));
ASSERT(NamespaceString::validDBName("foo$bar", NamespaceString::DollarInDbNameBehavior::Allow));
ASSERT(
!NamespaceString::validDBName("foo/bar", NamespaceString::DollarInDbNameBehavior::Allow));
ASSERT(
Reported by Cppcheck.
src/mongo/db/nesting_depth_test.cpp
1 issues
Line: 84
builder->doneFast();
}
TEST_F(NestingDepthFixture, CanInsertLargeNestedDocumentAtOrUnderDepthLimit) {
BSONObjBuilder insertDocumentOneLessThanLimit;
appendInsertCommandWithNestedDocument(&insertDocumentOneLessThanLimit,
BSONDepth::getMaxDepthForUserStorage() - 1);
assertCommandOK(kCollectionName, insertDocumentOneLessThanLimit.obj());
Reported by Cppcheck.
src/mongo/db/op_observer_impl_test.cpp
1 issues
Line: 197
}
};
TEST_F(OpObserverTest, StartIndexBuildExpectedOplogEntry) {
OpObserverImpl opObserver;
auto opCtx = cc().makeOperationContext();
auto uuid = CollectionUUID::gen();
NamespaceString nss("test.coll");
UUID indexBuildUUID = UUID::gen();
Reported by Cppcheck.
src/mongo/db/op_observer_registry_test.cpp
1 issues
Line: 138
}
};
TEST_F(OpObserverRegistryTest, NoObservers) {
OperationContextNoop opCtx;
// Check that it's OK to call observer methods with no observers registered.
registry.onDropDatabase(&opCtx, "test");
}
Reported by Cppcheck.
src/mongo/db/operation_context_test.cpp
1 issues
Line: 85
}
}
TEST(OperationContextTest, NoSessionIdNoTransactionNumber) {
auto serviceCtx = ServiceContext::make();
auto client = serviceCtx->makeClient("OperationContextTest");
auto opCtx = client->makeOperationContext();
ASSERT(!opCtx->getLogicalSessionId());
Reported by Cppcheck.
src/mongo/db/operation_id_test.cpp
1 issues
Line: 66
ASSERT(UniqueOperationIdRegistryTestHarness::isActive(*registry, 3));
}
TEST(OperationIdTest, OperationIdsAreUnique) {
auto registry = UniqueOperationIdRegistry::create();
auto slot = registry->acquireSlot();
ASSERT_EQ(slot.getId(), 1);
auto slot2 = registry->acquireSlot();
Reported by Cppcheck.