@@ -342,6 +342,8 @@ TEST_CASE("Collection", "[collection]") {
342
342
auto doc = find_doc.view ();
343
343
mongocxx::stdx::optional<bsoncxx::document::view> expected_sort{};
344
344
mongocxx::stdx::optional<bsoncxx::document::view> expected_hint{};
345
+ mongocxx::stdx::optional<bsoncxx::stdx::string_view> expected_comment{};
346
+
345
347
346
348
collection_find->interpose ([&](mongoc_collection_t *, mongoc_query_flags_t flags,
347
349
uint32_t skip, uint32_t limit, uint32_t batch_size,
@@ -365,6 +367,9 @@ TEST_CASE("Collection", "[collection]") {
365
367
REQUIRE (query_view[" $hint" ].get_utf8 () ==
366
368
expected_hint->operator [](" $hint" ).get_utf8 ());
367
369
}
370
+ if (expected_comment) {
371
+ REQUIRE (query_view[" $comment" ].get_utf8 ().value == *expected_comment);
372
+ }
368
373
REQUIRE (fields == NULL );
369
374
REQUIRE (read_prefs == NULL );
370
375
@@ -396,6 +401,14 @@ TEST_CASE("Collection", "[collection]") {
396
401
REQUIRE_NOTHROW (mongo_coll.find (doc, opts));
397
402
}
398
403
404
+ SECTION (" Succeeds with comment" ) {
405
+ expected_comment = " my comment" ;
406
+ options::find opts;
407
+ opts.comment (*expected_comment);
408
+
409
+ REQUIRE_NOTHROW (mongo_coll.find (doc, opts));
410
+ }
411
+
399
412
REQUIRE (collection_find_called);
400
413
}
401
414
0 commit comments