The following issues were found
src/mongo/db/bson/dotted_path_support_test.cpp
1 issues
Line: 60
0);
}
TEST(DottedPathSupport, ExtractElementAtPath) {
BSONObj obj = BSON("a" << 1 << "b" << BSON("a" << 2) << "c"
<< BSON_ARRAY(BSON("a" << 3) << BSON("a" << 4)));
ASSERT_EQUALS(1, dps::extractElementAtPath(obj, "a").numberInt());
ASSERT_EQUALS(2, dps::extractElementAtPath(obj, "b.a").numberInt());
ASSERT_EQUALS(3, dps::extractElementAtPath(obj, "c.0.a").numberInt());
Reported by Cppcheck.
src/mongo/db/cancelable_operation_context_test.cpp
1 issues
Line: 76
std::shared_ptr<ThreadPool> _threadPool;
};
TEST_F(CancelableOperationContextTest, ActsAsNormalOperationContext) {
auto serviceCtx = ServiceContext::make();
auto client = serviceCtx->makeClient("CancelableOperationContextTest");
auto opCtx = CancelableOperationContext{
client->makeOperationContext(), CancellationToken::uncancelable(), executor()};
Reported by Cppcheck.
src/mongo/db/catalog/capped_utils_test.cpp
1 issues
Line: 109
// and a multiple of 256.
const double cappedCollectionSize = 8192.0;
TEST_F(CappedUtilsTest, ConvertToCappedReturnsNamespaceNotFoundIfCollectionIsMissing) {
NamespaceString nss("test.t");
auto opCtx = makeOpCtx();
ASSERT_FALSE(collectionExists(opCtx.get(), nss));
ASSERT_THROWS_CODE(
convertToCapped(opCtx.get(), nss, 1000.0), DBException, ErrorCodes::NamespaceNotFound);
Reported by Cppcheck.
src/mongo/db/catalog/catalog_control_test.cpp
1 issues
Line: 74
_tc = {};
}
TEST_F(CatalogControlTest, CloseAndOpenCatalog) {
OperationContextNoop opCtx(&cc(), 0);
auto map = catalog::closeCatalog(&opCtx);
ASSERT_EQUALS(0U, map.size());
catalog::openCatalog(&opCtx, {}, Timestamp());
}
Reported by Cppcheck.
src/mongo/db/catalog/collection_catalog_test.cpp
1 issues
Line: 183
CollectionCatalog catalog;
};
TEST_F(CollectionCatalogResourceMapTest, EmptyTest) {
boost::optional<std::string> resource = catalog.lookupResourceName(firstResourceId);
ASSERT_EQ(boost::none, resource);
catalog.removeResource(secondResourceId, secondCollection);
resource = catalog.lookupResourceName(secondResourceId);
Reported by Cppcheck.
src/mongo/db/catalog/collection_impl.cpp
1 issues
Line: 1915
// Store new path components that cause this index to be multikey in catalog's
// index metadata.
for (size_t i = 0; i < multikeyPaths.size(); ++i) {
auto& indexMultikeyComponents = index->multikeyPaths[i];
for (const auto multikeyComponent : multikeyPaths[i]) {
auto result = indexMultikeyComponents.insert(multikeyComponent);
newPathIsMultikey = newPathIsMultikey || result.second;
somePathIsMultikey = true;
Reported by Cppcheck.
src/mongo/db/catalog/collection_options_test.cpp
1 issues
Line: 47
ASSERT_BSONOBJ_EQ(options.toBSON(), parsedOptions.toBSON());
}
TEST(CollectionOptions, SimpleRoundTrip) {
CollectionOptions options;
checkRoundTrip(options);
options.capped = true;
options.cappedSize = 10240;
Reported by Cppcheck.
src/mongo/db/catalog/collection_test.cpp
1 issues
Line: 70
ASSERT_OK(storageInterface()->createCollection(operationContext(), nss, options));
}
TEST_F(CollectionTest, CappedNotifierKillAndIsDead) {
NamespaceString nss("test.t");
makeCapped(nss);
AutoGetCollectionForRead acfr(operationContext(), nss);
const CollectionPtr& col = acfr.getCollection();
Reported by Cppcheck.
src/mongo/db/catalog/collection_validation_test.cpp
1 issues
Line: 202
// Verify that calling validate() on an empty collection with different validation levels returns an
// OK status.
TEST_F(CollectionValidationTest, ValidateEmpty) {
// Running on the ephemeralForTest storage engine.
foregroundValidate(operationContext(),
/*valid*/ true,
/*numRecords*/ 0,
/*numInvalidDocuments*/ 0,
Reported by Cppcheck.
src/mongo/db/catalog/collection_writer_test.cpp
1 issues
Line: 92
const NamespaceString kNss{"testdb", "testcol"};
};
TEST_F(CollectionWriterTest, Inplace) {
CollectionWriter writer(operationContext(), kNss, CollectionCatalog::LifetimeMode::kInplace);
// CollectionWriter in Inplace mode should operate directly on the Collection instance stored in
// the catalog. So no Collection copy should be made.
ASSERT_EQ(writer.get(), lookupCollectionFromCatalog());
Reported by Cppcheck.