Skip to content

Commit de161eb

Browse files
committed
CDRIVER-929 line-endings in test data files
1 parent 3e11c24 commit de161eb

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests/binary/* text eol=lf

.mci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ c_driver_variables:
138138
make
139139
msvc: &compile_msvc
140140
compile_script: |
141+
file "tests/binary/gridfs-large.dat"
141142
set -o errexit
142143
set -o verbose
143144
cmake="/cygdrive/c/cmake/bin/cmake"

tests/TestSuite.h

+10
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ extern "C" {
7272
#define ASSERT_CMPINT64(a, eq, b) ASSERT_CMPINT_HELPER(a, eq, b, PRId64)
7373
#define ASSERT_CMPUINT64(a, eq, b) ASSERT_CMPINT_HELPER(a, eq, b, PRIu64)
7474

75+
#define ASSERT_MEMCMP(a, b, n) \
76+
do { \
77+
if (0 != memcmp(a, b, n)) { \
78+
fprintf (stderr, \
79+
"Failed comparing %d bytes: \"%.*s\" != \"%.*s\"", \
80+
n, n, a, n, b); \
81+
abort (); \
82+
}\
83+
} while (0)
84+
7585

7686
#ifdef ASSERT_ALMOST_EQUAL
7787
# undef ASSERT_ALMOST_EQUAL

tests/test-mongoc-gridfs.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -337,23 +337,23 @@ test_read (void)
337337

338338
r = mongoc_gridfs_file_readv (file, iov, 2, 20, 0);
339339
ASSERT_CMPLONG (r, ==, 20L);
340-
ASSERT_CMPINT (memcmp (iov[0].iov_base, "Bacon ipsu", 10), ==, 0);
341-
ASSERT_CMPINT (memcmp (iov[1].iov_base, "m dolor si", 10), ==, 0);
340+
ASSERT_MEMCMP (iov[0].iov_base, "Bacon ipsu", 10);
341+
ASSERT_MEMCMP (iov[1].iov_base, "m dolor si", 10);
342342

343343
ASSERT_CMPINT (mongoc_gridfs_file_seek (file, 1, SEEK_SET), ==, 0);
344344
r = mongoc_gridfs_file_readv (file, iov, 2, 20, 0);
345345

346346
ASSERT_CMPLONG (r, ==, 20L);
347-
ASSERT_CMPINT (memcmp (iov[0].iov_base, "acon ipsum", 10), ==, 0);
348-
ASSERT_CMPINT (memcmp (iov[1].iov_base, " dolor sit", 10), ==, 0);
347+
ASSERT_MEMCMP (iov[0].iov_base, "acon ipsum", 10);
348+
ASSERT_MEMCMP (iov[1].iov_base, " dolor sit", 10);
349349

350350
ASSERT_CMPINT (mongoc_gridfs_file_seek (file, file->chunk_size-1, SEEK_SET), ==, 0);
351351
r = mongoc_gridfs_file_readv (file, iov, 2, 20, 0);
352352

353353
ASSERT_CMPLONG (r, ==, 20L);
354354
ASSERT_CMPINT64 (mongoc_gridfs_file_tell (file), ==, (uint64_t)(file->chunk_size+19));
355-
ASSERT_CMPINT (memcmp (iov[0].iov_base, "turducken ", 10), ==, 0);
356-
ASSERT_CMPINT (memcmp (iov[1].iov_base, "spare ribs", 10), ==, 0);
355+
ASSERT_MEMCMP (iov[0].iov_base, "turducken ", 10);
356+
ASSERT_MEMCMP (iov[1].iov_base, "spare ribs", 10);
357357

358358
assert (mongoc_gridfs_file_seek (file, 20, SEEK_END) == 0);
359359
previous_errno = errno;

0 commit comments

Comments
 (0)