File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
src/mongocxx/test/v_noabi/gridfs Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 2020#include < cstdlib>
2121#include < fstream>
2222#include < functional>
23+ #include < memory>
2324#include < numeric>
2425#include < sstream>
2526#include < vector>
@@ -525,22 +526,21 @@ TEST_CASE("mongocxx::gridfs::downloader::read with arbitrary sizes", "[gridfs::d
525526 std::int32_t read_size = 0 ;
526527
527528 auto run_test = [&]() {
528- REQUIRE (read_size != 0 );
529+ REQUIRE (read_size > 0 );
529530
530531 bsoncxx::types::bson_value::view id{bsoncxx::types::b_oid{bsoncxx::oid{}}};
531532 std::vector<std::uint8_t > expected = manual_gridfs_initialize (db, file_length, chunk_size, id);
532533
533534 // Allocate a buffer large enough to fit the data read from the downloader.
534- std::vector<std::uint8_t > buffer;
535- buffer.reserve (static_cast <std::size_t >(read_size));
535+ std::unique_ptr<std::uint8_t []> buffer{new std::uint8_t [static_cast <std::size_t >(read_size)]};
536536
537537 std::size_t total_bytes_read = 0 ;
538538 auto downloader = bucket.open_download_stream (bsoncxx::types::bson_value::view{id});
539539
540- while (std::size_t bytes_read = downloader.read (buffer.data (), static_cast <std::size_t >(read_size))) {
540+ while (std::size_t bytes_read = downloader.read (buffer.get (), static_cast <std::size_t >(read_size))) {
541541 std::vector<std::uint8_t > expected_bytes{
542542 expected.data () + total_bytes_read, expected.data () + total_bytes_read + bytes_read};
543- std::vector<std::uint8_t > actual_bytes{buffer.data (), buffer.data () + bytes_read};
543+ std::vector<std::uint8_t > actual_bytes{buffer.get (), buffer.get () + bytes_read};
544544
545545 REQUIRE (expected_bytes == actual_bytes);
546546
You can’t perform that action at this time.
0 commit comments