@@ -707,6 +707,53 @@ test_mongoc_uri_write_concern (void)
707
707
}
708
708
}
709
709
710
+ static void
711
+ test_mongoc_uri_read_concern (void )
712
+ {
713
+ const mongoc_read_concern_t * rc ;
714
+ mongoc_uri_t * uri ;
715
+
716
+ uri = mongoc_uri_new ("mongodb://localhost/?readConcernLevel=majority" );
717
+ rc = mongoc_uri_get_read_concern (uri );
718
+ ASSERT_CMPSTR (mongoc_read_concern_get_level (rc ), "majority" );
719
+ mongoc_uri_destroy (uri );
720
+
721
+ uri = mongoc_uri_new ("mongodb://localhost/?readConcernLevel=" MONGOC_READ_CONCERN_LEVEL_MAJORITY );
722
+ rc = mongoc_uri_get_read_concern (uri );
723
+ ASSERT_CMPSTR (mongoc_read_concern_get_level (rc ), "majority" );
724
+ mongoc_uri_destroy (uri );
725
+
726
+
727
+ uri = mongoc_uri_new ("mongodb://localhost/?readConcernLevel=local" );
728
+ rc = mongoc_uri_get_read_concern (uri );
729
+ ASSERT_CMPSTR (mongoc_read_concern_get_level (rc ), "local" );
730
+ mongoc_uri_destroy (uri );
731
+
732
+ uri = mongoc_uri_new ("mongodb://localhost/?readConcernLevel=" MONGOC_READ_CONCERN_LEVEL_LOCAL );
733
+ rc = mongoc_uri_get_read_concern (uri );
734
+ ASSERT_CMPSTR (mongoc_read_concern_get_level (rc ), "local" );
735
+ mongoc_uri_destroy (uri );
736
+
737
+
738
+ uri = mongoc_uri_new ("mongodb://localhost/?readConcernLevel=randomstuff" );
739
+ rc = mongoc_uri_get_read_concern (uri );
740
+ ASSERT_CMPSTR (mongoc_read_concern_get_level (rc ), "randomstuff" );
741
+ mongoc_uri_destroy (uri );
742
+
743
+
744
+ uri = mongoc_uri_new ("mongodb://localhost/" );
745
+ rc = mongoc_uri_get_read_concern (uri );
746
+ ASSERT (mongoc_read_concern_get_level (rc ) == NULL );
747
+ mongoc_uri_destroy (uri );
748
+
749
+
750
+ uri = mongoc_uri_new ("mongodb://localhost/?readConcernLevel=" );
751
+ rc = mongoc_uri_get_read_concern (uri );
752
+ ASSERT_CMPSTR (mongoc_read_concern_get_level (rc ), "" );
753
+ mongoc_uri_destroy (uri );
754
+ }
755
+
756
+
710
757
711
758
void
712
759
test_uri_install (TestSuite * suite )
@@ -715,6 +762,7 @@ test_uri_install (TestSuite *suite)
715
762
TestSuite_Add (suite , "/Uri/new_for_host_port" , test_mongoc_uri_new_for_host_port );
716
763
TestSuite_Add (suite , "/Uri/unescape" , test_mongoc_uri_unescape );
717
764
TestSuite_Add (suite , "/Uri/read_prefs" , test_mongoc_uri_read_prefs );
765
+ TestSuite_Add (suite , "/Uri/read_concern" , test_mongoc_uri_read_concern );
718
766
TestSuite_Add (suite , "/Uri/write_concern" , test_mongoc_uri_write_concern );
719
767
TestSuite_Add (suite , "/HostList/from_string" , test_mongoc_host_list_from_string );
720
768
TestSuite_Add (suite , "/Uri/functions" , test_mongoc_uri_functions );
0 commit comments