<commit_before>#include <fcntl.h>
#include <mongoc.h>
#include <mongoc-buffer-private.h>

#include "mongoc-tests.h"


static void
test_mongoc_buffer_basic (void)
{
   bson_uint8_t lbuf[1024];
   mongoc_stream_t *stream;
   mongoc_buffer_t buf;
   bson_uint8_t *data = bson_malloc0(1024);
   bson_error_t error = { 0 };
   struct iovec iov;
   int fd;

   fd = open("tests/binary/reply1.dat", O_RDONLY);
   assert(fd >= 0);

   stream = mongoc_stream_new_from_unix(fd);
   assert(stream);

   mongoc_buffer_init(&buf, data, 1024, bson_realloc);
   assert(TRUE == mongoc_buffer_fill(&buf, stream, 536, &error));

   iov.iov_base = lbuf;
   iov.iov_len = 1024;
   assert_cmpint(536, ==, mongoc_buffer_readv(&buf, &iov, 1));
   assert_cmpint(0, ==, mongoc_buffer_readv(&buf, &iov, 1));
   assert(FALSE == mongoc_buffer_fill(&buf, stream, 1, &error));
   assert_cmpint(0, ==, mongoc_buffer_readv(&buf, &iov, 1));
   mongoc_stream_close(stream);
   assert(FALSE == mongoc_buffer_fill(&buf, stream, 1, &error));
   assert_cmpint(0, ==, mongoc_buffer_readv(&buf, &iov, 1));
}


int
main (int   argc,
      char *argv[])
{
   run_test("/mongoc/buffer/basic", test_mongoc_buffer_basic);

   return 0;
}
<commit_msg>tests: update buffer test for new api.<commit_after>#include <fcntl.h>
#include <mongoc.h>
#include <mongoc-buffer-private.h>

#include "mongoc-tests.h"


static void
test_mongoc_buffer_basic (void)
{
   mongoc_stream_t *stream;
   mongoc_buffer_t buf;
   bson_uint8_t *data = bson_malloc0(1024);
   bson_error_t error = { 0 };
   bson_bool_t r;
   int fd;

   fd = open("tests/binary/reply1.dat", O_RDONLY);
   assert(fd >= 0);

   stream = mongoc_stream_new_from_unix(fd);
   assert(stream);

   mongoc_buffer_init(&buf, data, 1024, bson_realloc);
   r = mongoc_buffer_fill(&buf, stream, &error);
   assert(r == TRUE);
   assert_cmpint(buf.len, ==, 536);

   mongoc_buffer_destroy(&buf);
}


int
main (int   argc,
      char *argv[])
{
   run_test("/mongoc/buffer/basic", test_mongoc_buffer_basic);

   return 0;
}

{'fraction_non_alphanumeric': 0.14886251236399603, 'fraction_numerical': 0.027200791295746787, 'mean_word_length': 4.409090909090909, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1523350', 'n_tokens_mistral': 854, 'n_tokens_neox': 806, 'n_words': 150}