The following issues were found
src/mongo/db/query/index_bounds_test.cpp
1 issues
Line: 70
ASSERT_FALSE(bounds.isValidFor(BSON("bar" << 1), 1));
}
TEST(IndexBoundsTest, ValidTwoFields) {
OrderedIntervalList list("foo");
list.intervals.push_back(Interval(BSON("" << 7 << "" << 20), true, true));
IndexBounds bounds;
bounds.fields.push_back(list);
Reported by Cppcheck.
src/mongo/db/query/index_entry_test.cpp
1 issues
Line: 61
nullptr};
}
TEST(QueryPlannerIXSelectTest, IndexedFieldHasMultikeyComponents) {
auto indexEntry = makeIndexEntry(BSON("a" << 1 << "b.c" << 1), {{}, {}});
ASSERT_FALSE(indexEntry.pathHasMultikeyComponent("a"_sd));
ASSERT_FALSE(indexEntry.pathHasMultikeyComponent("b.c"_sd));
indexEntry = makeIndexEntry(BSON("a" << 1 << "b" << 1), {{}, {0U}});
Reported by Cppcheck.
src/mongo/db/query/interval_test.cpp
1 issues
Line: 60
ASSERT_NOT_EQUALS(a.compare(e), Interval::INTERVAL_EQUALS);
}
TEST(Comparison, Contains) {
Interval a(BSON("" << 0 << "" << 10), true, true);
Interval b(BSON("" << 1 << "" << 9), true, true);
ASSERT_EQUALS(a.compare(b), Interval::INTERVAL_CONTAINS);
Interval c(BSON("" << 0 << "" << 10), true, false);
Reported by Cppcheck.
src/mongo/db/query/killcursors_request_test.cpp
1 issues
Line: 43
const IDLParserErrorContext ctxt("killCursors");
TEST(KillCursorsRequestTest, parseSuccess) {
auto bsonObj = BSON("killCursors"
<< "coll"
<< "cursors" << BSON_ARRAY(CursorId(123) << CursorId(456)) << "$db"
<< "db");
KillCursorsCommandRequest request = KillCursorsCommandRequest::parse(ctxt, bsonObj);
Reported by Cppcheck.
src/mongo/db/query/lru_key_value_test.cpp
1 issues
Line: 61
/**
* Test that we can add an entry and get it back out.
*/
TEST(LRUKeyValueTest, BasicAddGet) {
LRUKeyValue<int, int> cache(100);
cache.add(1, new int(2));
assertInKVStore(cache, 1, 2);
}
Reported by Cppcheck.
src/mongo/db/query/map_reduce_output_format_test.cpp
1 issues
Line: 54
ASSERT_BSONOBJ_EQ(fromjson("{results: [{a: 1}, {b: 1}]}"), builder.obj());
}
TEST(MapReduceOutputFormat, FormatEmptyInlineMapReduceResponse) {
BSONArrayBuilder documents;
BSONObjBuilder builder;
map_reduce_output_format::appendInlineResponse(documents.arr(), &builder);
ASSERT_BSONOBJ_EQ(fromjson("{results: []}"), builder.obj());
}
Reported by Cppcheck.
src/mongo/db/query/parsed_distinct_test.cpp
1 issues
Line: 47
static const NamespaceString testns("testdb.testcoll");
static const bool isExplain = true;
TEST(ParsedDistinctTest, ConvertToAggregationNoQuery) {
QueryTestServiceContext serviceContext;
auto uniqueTxn = serviceContext.makeOperationContext();
OperationContext* opCtx = uniqueTxn.get();
auto pd = ParsedDistinct::parse(opCtx,
Reported by Cppcheck.
src/mongo/db/query/plan_cache_indexability_test.cpp
1 issues
Line: 89
}
// Test sparse index discriminators for a simple sparse index.
TEST(PlanCacheIndexabilityTest, SparseIndexSimple) {
PlanCacheIndexabilityState state;
auto keyPattern = BSON("a" << 1);
state.updateDiscriminators(
{IndexEntry(keyPattern,
IndexNames::nameToType(IndexNames::findPluginName(keyPattern)),
Reported by Cppcheck.
src/mongo/db/query/plan_cache_test.cpp
1 issues
Line: 395
* and can be managed with the cache DB commands.
*/
TEST(PlanCacheTest, ShouldCacheQueryBasic) {
unique_ptr<CanonicalQuery> cq(canonicalize("{a: 1}"));
assertShouldCacheQuery(*cq);
}
TEST(PlanCacheTest, ShouldCacheQuerySort) {
Reported by Cppcheck.
src/mongo/db/query/plan_executor_sbe.cpp
1 issues
Line: 233
Column: 20
CWE codes:
362
*_resumeRecordIdSlot, _tagLastRecordId, _valLastRecordId, false);
}
_state = State::kOpened;
_root->open(false);
}
invariant(_state == State::kOpened);
auto result =
Reported by FlawFinder.