@@ -331,7 +331,6 @@ test_bulk (void)
331
331
bson_t del ;
332
332
bson_t up ;
333
333
bson_t doc = BSON_INITIALIZER ;
334
- bool r ;
335
334
336
335
client = test_framework_client_new ();
337
336
assert (client );
@@ -360,8 +359,8 @@ test_bulk (void)
360
359
mongoc_bulk_operation_remove (bulk , & del );
361
360
bson_destroy (& del );
362
361
363
- r = mongoc_bulk_operation_execute (bulk , & reply , & error );
364
- assert ( r );
362
+ ASSERT_OR_PRINT ( mongoc_bulk_operation_execute (bulk , & reply , & error ),
363
+ error );
365
364
366
365
ASSERT_MATCH (& reply , "{'nInserted': 4,"
367
366
" 'nMatched': 4,"
@@ -373,8 +372,7 @@ test_bulk (void)
373
372
374
373
bson_destroy (& reply );
375
374
376
- r = mongoc_collection_drop (collection , & error );
377
- assert (r );
375
+ ASSERT_OR_PRINT (mongoc_collection_drop (collection , & error ), error );
378
376
379
377
mongoc_bulk_operation_destroy (bulk );
380
378
mongoc_collection_destroy (collection );
@@ -393,7 +391,6 @@ test_insert (bool ordered)
393
391
bson_t reply ;
394
392
bson_t doc = BSON_INITIALIZER ;
395
393
bson_t query = BSON_INITIALIZER ;
396
- bool r ;
397
394
mongoc_cursor_t * cursor ;
398
395
const bson_t * inserted_doc ;
399
396
@@ -411,8 +408,8 @@ test_insert (bool ordered)
411
408
mongoc_bulk_operation_insert (bulk , & doc );
412
409
mongoc_bulk_operation_insert (bulk , & doc );
413
410
414
- r = ( bool ) mongoc_bulk_operation_execute (bulk , & reply , & error );
415
- assert ( r );
411
+ ASSERT_OR_PRINT ( mongoc_bulk_operation_execute (bulk , & reply , & error ),
412
+ error );
416
413
417
414
ASSERT_MATCH (& reply , "{'nInserted': 2,"
418
415
" 'nMatched': 0,"
@@ -432,8 +429,7 @@ test_insert (bool ordered)
432
429
assert (oid_created_on_client (inserted_doc ));
433
430
}
434
431
435
- r = mongoc_collection_drop (collection , & error );
436
- assert (r );
432
+ ASSERT_OR_PRINT (mongoc_collection_drop (collection , & error ), error );
437
433
438
434
mongoc_cursor_destroy (cursor );
439
435
bson_destroy (& query );
@@ -520,7 +516,6 @@ test_upsert (bool ordered)
520
516
bson_t reply ;
521
517
bson_t * sel ;
522
518
bson_t * doc ;
523
- bool r ;
524
519
525
520
client = test_framework_client_new ();
526
521
assert (client );
@@ -537,8 +532,8 @@ test_upsert (bool ordered)
537
532
538
533
mongoc_bulk_operation_update (bulk , sel , doc , true);
539
534
540
- r = mongoc_bulk_operation_execute (bulk , & reply , & error );
541
- assert ( r );
535
+ ASSERT_OR_PRINT ( mongoc_bulk_operation_execute (bulk , & reply , & error ),
536
+ error );
542
537
543
538
ASSERT_MATCH (& reply , "{'nInserted': 0,"
544
539
" 'nMatched': 0,"
@@ -561,8 +556,8 @@ test_upsert (bool ordered)
561
556
doc = tmp_bson ("{'$set': {'hello': 'there'}}" );
562
557
563
558
mongoc_bulk_operation_update (bulk , sel , doc , false);
564
- r = mongoc_bulk_operation_execute (bulk , & reply , & error );
565
- assert ( r );
559
+ ASSERT_OR_PRINT ( mongoc_bulk_operation_execute (bulk , & reply , & error ),
560
+ error );
566
561
567
562
ASSERT_MATCH (& reply , "{'nInserted': 0,"
568
563
" 'nMatched': 0,"
@@ -574,8 +569,7 @@ test_upsert (bool ordered)
574
569
check_n_modified (has_write_cmds , & reply , 0 );
575
570
ASSERT_COUNT (1 , collection ); /* doc remains from previous operation */
576
571
577
- r = mongoc_collection_drop (collection , & error );
578
- assert (r );
572
+ ASSERT_OR_PRINT (mongoc_collection_drop (collection , & error ), error );
579
573
580
574
bson_destroy (& reply );
581
575
mongoc_bulk_operation_destroy (bulk );
@@ -728,8 +722,7 @@ test_upserted_index (bool ordered)
728
722
check_n_modified (has_write_cmds , & reply , 34 );
729
723
ASSERT_COUNT (18 , collection );
730
724
731
- r = mongoc_collection_drop (collection , & error );
732
- assert (r );
725
+ ASSERT_OR_PRINT (mongoc_collection_drop (collection , & error ), error );
733
726
734
727
bson_destroy (& reply );
735
728
mongoc_bulk_operation_destroy (bulk );
@@ -788,8 +781,8 @@ test_update_one (bool ordered)
788
781
sel = tmp_bson ("{}" );
789
782
doc = tmp_bson ("{'$set': {'hello': 'there'}}" );
790
783
mongoc_bulk_operation_update_one (bulk , sel , doc , true);
791
- r = ( bool )mongoc_bulk_operation_execute (bulk , & reply , & error );
792
- assert ( r );
784
+ ASSERT_OR_PRINT (( bool )mongoc_bulk_operation_execute (bulk , & reply , & error ),
785
+ error );
793
786
794
787
ASSERT_MATCH (& reply , "{'nInserted': 0,"
795
788
" 'nMatched': 1,"
@@ -801,8 +794,7 @@ test_update_one (bool ordered)
801
794
check_n_modified (has_write_cmds , & reply , 1 );
802
795
ASSERT_COUNT (2 , collection );
803
796
804
- r = mongoc_collection_drop (collection , & error );
805
- assert (r );
797
+ ASSERT_OR_PRINT (mongoc_collection_drop (collection , & error ), error );
806
798
807
799
bson_destroy (& reply );
808
800
mongoc_bulk_operation_destroy (bulk );
@@ -861,8 +853,8 @@ test_replace_one (bool ordered)
861
853
sel = tmp_bson ("{}" );
862
854
doc = tmp_bson ("{'hello': 'there'}" );
863
855
mongoc_bulk_operation_replace_one (bulk , sel , doc , true);
864
- r = ( bool )mongoc_bulk_operation_execute (bulk , & reply , & error );
865
- assert ( r );
856
+ ASSERT_OR_PRINT (( bool )mongoc_bulk_operation_execute (bulk , & reply , & error ),
857
+ error );
866
858
867
859
ASSERT_MATCH (& reply , "{'nInserted': 0,"
868
860
" 'nMatched': 1,"
@@ -874,8 +866,7 @@ test_replace_one (bool ordered)
874
866
check_n_modified (has_write_cmds , & reply , 1 );
875
867
ASSERT_COUNT (2 , collection );
876
868
877
- r = mongoc_collection_drop (collection , & error );
878
- assert (r );
869
+ ASSERT_OR_PRINT (mongoc_collection_drop (collection , & error ), error );
879
870
880
871
bson_destroy (& reply );
881
872
mongoc_bulk_operation_destroy (bulk );
@@ -915,8 +906,8 @@ test_upsert_large ()
915
906
bson_append_document_end (& doc , & child );
916
907
917
908
mongoc_bulk_operation_update (bulk , sel , & doc , true);
918
- r = ( bool )mongoc_bulk_operation_execute (bulk , & reply , & error );
919
- assert ( r );
909
+ ASSERT_OR_PRINT (( bool )mongoc_bulk_operation_execute (bulk , & reply , & error ),
910
+ error );
920
911
921
912
ASSERT_MATCH (& reply , "{'nInserted': 0,"
922
913
" 'nMatched': 0,"
@@ -968,7 +959,6 @@ test_update (bool ordered)
968
959
bson_t * sel ;
969
960
bson_t * bad_update_doc = tmp_bson ("{'foo': 'bar'}" );
970
961
bson_t * update_doc ;
971
- bool r ;
972
962
973
963
client = test_framework_client_new ();
974
964
assert (client );
@@ -993,8 +983,8 @@ test_update (bool ordered)
993
983
994
984
update_doc = tmp_bson ("{'$set': {'foo': 'bar'}}" );
995
985
mongoc_bulk_operation_update (bulk , sel , update_doc , false);
996
- r = ( bool ) mongoc_bulk_operation_execute (bulk , & reply , & error );
997
- assert ( r );
986
+ ASSERT_OR_PRINT ( mongoc_bulk_operation_execute (bulk , & reply , & error ),
987
+ error );
998
988
999
989
ASSERT_MATCH (& reply , "{'nInserted': 0,"
1000
990
" 'nMatched': 2,"
@@ -1007,8 +997,8 @@ test_update (bool ordered)
1007
997
check_n_modified (has_write_cmds , & reply , 1 );
1008
998
ASSERT_COUNT (3 , collection );
1009
999
1010
- r = mongoc_collection_drop (collection , & error );
1011
- assert ( r );
1000
+ ASSERT_OR_PRINT ( mongoc_collection_drop (collection , & error ),
1001
+ error );
1012
1002
1013
1003
mongoc_bulk_operation_destroy (bulk );
1014
1004
bson_destroy (& reply );
@@ -1066,8 +1056,8 @@ test_index_offset (void)
1066
1056
mongoc_bulk_operation_remove_one (bulk , sel );
1067
1057
mongoc_bulk_operation_update (bulk , sel , doc , true);
1068
1058
1069
- r = mongoc_bulk_operation_execute (bulk , & reply , & error );
1070
- assert ( r );
1059
+ ASSERT_OR_PRINT ( mongoc_bulk_operation_execute (bulk , & reply , & error ),
1060
+ error );
1071
1061
1072
1062
ASSERT_MATCH (& reply , "{'nInserted': 0,"
1073
1063
" 'nMatched': 0,"
@@ -1081,8 +1071,8 @@ test_index_offset (void)
1081
1071
1082
1072
bson_destroy (& reply );
1083
1073
1084
- r = mongoc_collection_drop (collection , & error );
1085
- assert ( r );
1074
+ ASSERT_OR_PRINT ( mongoc_collection_drop (collection , & error ),
1075
+ error );
1086
1076
1087
1077
mongoc_bulk_operation_destroy (bulk );
1088
1078
mongoc_collection_destroy (collection );
@@ -1099,7 +1089,6 @@ test_single_ordered_bulk ()
1099
1089
mongoc_bulk_operation_t * bulk ;
1100
1090
bson_t reply ;
1101
1091
bson_error_t error ;
1102
- bool r ;
1103
1092
1104
1093
client = test_framework_client_new ();
1105
1094
assert (client );
@@ -1123,8 +1112,8 @@ test_single_ordered_bulk ()
1123
1112
tmp_bson ("{'a': 3}" ));
1124
1113
mongoc_bulk_operation_remove (bulk ,
1125
1114
tmp_bson ("{'a': 3}" ));
1126
- r = ( bool )mongoc_bulk_operation_execute (bulk , & reply , & error );
1127
- assert ( r );
1115
+ ASSERT_OR_PRINT (( bool )mongoc_bulk_operation_execute (bulk , & reply , & error ),
1116
+ error );
1128
1117
1129
1118
ASSERT_MATCH (& reply , "{'nInserted': 2,"
1130
1119
" 'nMatched': 1,"
@@ -1440,7 +1429,6 @@ test_single_unordered_bulk ()
1440
1429
mongoc_bulk_operation_t * bulk ;
1441
1430
bson_t reply ;
1442
1431
bson_error_t error ;
1443
- bool r ;
1444
1432
1445
1433
client = test_framework_client_new ();
1446
1434
assert (client );
@@ -1462,8 +1450,8 @@ test_single_unordered_bulk ()
1462
1450
tmp_bson ("{'a': 3}" ));
1463
1451
mongoc_bulk_operation_remove (bulk ,
1464
1452
tmp_bson ("{'a': 3}" ));
1465
- r = ( bool )mongoc_bulk_operation_execute (bulk , & reply , & error );
1466
- assert ( r );
1453
+ ASSERT_OR_PRINT (( bool )mongoc_bulk_operation_execute (bulk , & reply , & error ),
1454
+ error );
1467
1455
1468
1456
ASSERT_MATCH (& reply , "{'nInserted': 2,"
1469
1457
" 'nMatched': 1,"
@@ -1793,8 +1781,8 @@ test_large_inserts_ordered ()
1793
1781
mongoc_bulk_operation_insert (bulk , big_doc );
1794
1782
}
1795
1783
1796
- r = ( bool )mongoc_bulk_operation_execute (bulk , & reply , & error );
1797
- assert ( r );
1784
+ ASSERT_OR_PRINT (( bool )mongoc_bulk_operation_execute (bulk , & reply , & error ),
1785
+ error );
1798
1786
assert_n_inserted (6 , & reply );
1799
1787
ASSERT_COUNT (6 , collection );
1800
1788
@@ -1874,8 +1862,8 @@ test_large_inserts_unordered ()
1874
1862
mongoc_bulk_operation_insert (bulk , big_doc );
1875
1863
}
1876
1864
1877
- r = ( bool )mongoc_bulk_operation_execute (bulk , & reply , & error );
1878
- assert ( r );
1865
+ ASSERT_OR_PRINT (( bool )mongoc_bulk_operation_execute (bulk , & reply , & error ),
1866
+ error );
1879
1867
assert_n_inserted (6 , & reply );
1880
1868
ASSERT_COUNT (6 , collection );
1881
1869
@@ -1895,7 +1883,6 @@ _test_numerous (bool ordered)
1895
1883
mongoc_bulk_operation_t * bulk ;
1896
1884
bson_t reply ;
1897
1885
bson_error_t error ;
1898
- bool r ;
1899
1886
int n_docs = 4100 ; /* exceeds max write batch size of 1000 */
1900
1887
bson_t doc ;
1901
1888
bson_iter_t iter ;
@@ -1919,8 +1906,8 @@ _test_numerous (bool ordered)
1919
1906
mongoc_bulk_operation_insert (bulk , & doc );
1920
1907
}
1921
1908
1922
- r = ( bool )mongoc_bulk_operation_execute (bulk , & reply , & error );
1923
- assert ( r );
1909
+ ASSERT_OR_PRINT (( bool )mongoc_bulk_operation_execute (bulk , & reply , & error ),
1910
+ error );
1924
1911
1925
1912
assert_n_inserted (n_docs , & reply );
1926
1913
ASSERT_COUNT (n_docs , collection );
@@ -1935,8 +1922,8 @@ _test_numerous (bool ordered)
1935
1922
mongoc_bulk_operation_remove_one (bulk , & doc );
1936
1923
}
1937
1924
1938
- r = ( bool )mongoc_bulk_operation_execute (bulk , & reply , & error );
1939
- assert ( r );
1925
+ ASSERT_OR_PRINT (( bool )mongoc_bulk_operation_execute (bulk , & reply , & error ),
1926
+ error );
1940
1927
1941
1928
assert_n_removed (n_docs / 2 , & reply );
1942
1929
ASSERT_COUNT (n_docs / 2 , collection );
@@ -1951,8 +1938,8 @@ _test_numerous (bool ordered)
1951
1938
mongoc_bulk_operation_remove (bulk , & doc );
1952
1939
}
1953
1940
1954
- r = ( bool )mongoc_bulk_operation_execute (bulk , & reply , & error );
1955
- assert ( r );
1941
+ ASSERT_OR_PRINT (( bool )mongoc_bulk_operation_execute (bulk , & reply , & error ),
1942
+ error );
1956
1943
1957
1944
assert_n_removed (n_docs / 2 , & reply );
1958
1945
ASSERT_COUNT (0 , collection );
@@ -2061,7 +2048,6 @@ test_bulk_edge_case_372 (bool ordered)
2061
2048
bson_t * selector ;
2062
2049
bson_t * update ;
2063
2050
bson_t reply ;
2064
- bool r ;
2065
2051
2066
2052
client = test_framework_client_new ();
2067
2053
assert (client );
@@ -2093,13 +2079,12 @@ test_bulk_edge_case_372 (bool ordered)
2093
2079
mongoc_bulk_operation_replace_one (bulk , selector , update , true);
2094
2080
}
2095
2081
2096
- r = mongoc_bulk_operation_execute (bulk , & reply , & error );
2097
- if (!r ) fprintf (stderr , "%s\n" , error .message );
2098
- assert (r );
2099
2082
2100
2083
#if 0
2101
2084
printf ("%s\n" , bson_as_json (& reply , NULL ));
2102
2085
#endif
2086
+ ASSERT_OR_PRINT (mongoc_bulk_operation_execute (bulk , & reply , & error ),
2087
+ error );
2103
2088
2104
2089
ASSERT_MATCH (& reply , "{'nInserted': 0,"
2105
2090
" 'nMatched': 0,"
@@ -2187,8 +2172,8 @@ test_bulk_new (void)
2187
2172
assert (error .code = MONGOC_ERROR_COMMAND_INVALID_ARG );
2188
2173
2189
2174
mongoc_bulk_operation_insert (bulk , & empty );
2190
- r = mongoc_bulk_operation_execute (bulk , NULL , & error );
2191
- assert ( r );
2175
+ ASSERT_OR_PRINT ( mongoc_bulk_operation_execute (bulk , NULL , & error ),
2176
+ error );
2192
2177
2193
2178
mongoc_bulk_operation_destroy (bulk );
2194
2179
0 commit comments