]> granicus.if.org Git - transmission/commitdiff
Make use of new checking capabilities in unit tests
authorMike Gelfand <mikedld@mikedld.com>
Tue, 30 May 2017 17:56:12 +0000 (20:56 +0300)
committerMike Gelfand <mikedld@mikedld.com>
Tue, 30 May 2017 17:56:12 +0000 (20:56 +0300)
17 files changed:
libtransmission/bitfield-test.c
libtransmission/crypto-test.c
libtransmission/error-test.c
libtransmission/file-test.c
libtransmission/json-test.c
libtransmission/magnet-test.c
libtransmission/makemeta-test.c
libtransmission/move-test.c
libtransmission/peer-msgs-test.c
libtransmission/quark-test.c
libtransmission/rename-test.c
libtransmission/rpc-test.c
libtransmission/session-test.c
libtransmission/tr-getopt-test.c
libtransmission/utils-test.c
libtransmission/variant-test.c
libtransmission/watchdir-test.c

index 914ee3cba4a4705532fa649632a7c57fd942cb5c..3ba9f41fe051304e1fff7c4f4efc15352dd39fe3 100644 (file)
@@ -59,7 +59,7 @@ static int test_bitfield_count_range(void)
     }
 
     count2 = tr_bitfieldCountRange(&bf, begin, end);
-    check(count1 == count2);
+    check_int(count1, ==, count2);
 
     /* cleanup */
     tr_bitfieldDestruct(&bf);
@@ -84,7 +84,7 @@ static int test_bitfields(void)
 
     for (unsigned int i = 0; i < bitcount; i++)
     {
-        check(tr_bitfieldHas(&field, i) == (i % 7 == 0));
+        check_bool(tr_bitfieldHas(&field, i), ==, (i % 7 == 0));
     }
 
     /* test tr_bitfieldAddRange */
@@ -106,7 +106,7 @@ static int test_bitfields(void)
 
     for (unsigned int i = 0; i < bitcount; i++)
     {
-        check(tr_bitfieldHas(&field, i) == (i % 7 == 0));
+        check_bool(tr_bitfieldHas(&field, i), ==, (i % 7 == 0));
     }
 
     /* test tr_bitfieldRemRange in the middle of a boundary */
@@ -115,7 +115,7 @@ static int test_bitfields(void)
 
     for (unsigned int i = 0; i < 64; i++)
     {
-        check(tr_bitfieldHas(&field, i) == (i < 4 || i >= 21));
+        check_bool(tr_bitfieldHas(&field, i), ==, (i < 4 || i >= 21));
     }
 
     /* test tr_bitfieldRemRange on the boundaries */
@@ -124,7 +124,7 @@ static int test_bitfields(void)
 
     for (unsigned int i = 0; i < 64; i++)
     {
-        check(tr_bitfieldHas(&field, i) == (i < 8 || i >= 24));
+        check_bool(tr_bitfieldHas(&field, i), ==, (i < 8 || i >= 24));
     }
 
     /* test tr_bitfieldRemRange when begin & end is on the same word */
@@ -133,7 +133,7 @@ static int test_bitfields(void)
 
     for (unsigned int i = 0; i < 64; i++)
     {
-        check(tr_bitfieldHas(&field, i) == (i < 4 || i >= 5));
+        check_bool(tr_bitfieldHas(&field, i), ==, (i < 4 || i >= 5));
     }
 
     /* test tr_bitfieldAddRange */
@@ -142,7 +142,7 @@ static int test_bitfields(void)
 
     for (unsigned int i = 0; i < 64; i++)
     {
-        check(tr_bitfieldHas(&field, i) == (4 <= i && i < 21));
+        check_bool(tr_bitfieldHas(&field, i), ==, (4 <= i && i < 21));
     }
 
     /* test tr_bitfieldAddRange on the boundaries */
@@ -151,7 +151,7 @@ static int test_bitfields(void)
 
     for (unsigned int i = 0; i < 64; i++)
     {
-        check(tr_bitfieldHas(&field, i) == (8 <= i && i < 24));
+        check_bool(tr_bitfieldHas(&field, i), ==, (8 <= i && i < 24));
     }
 
     /* test tr_bitfieldAddRange when begin & end is on the same word */
@@ -160,7 +160,7 @@ static int test_bitfields(void)
 
     for (unsigned int i = 0; i < 64; i++)
     {
-        check(tr_bitfieldHas(&field, i) == (4 <= i && i < 5));
+        check_bool(tr_bitfieldHas(&field, i), ==, (4 <= i && i < 5));
     }
 
     tr_bitfieldDestruct(&field);
index e60f43b5874182b88e38e6537c6cde8340364815..b6eecd1f802c2eae2ab10f8f665c614039acd20c 100644 (file)
@@ -30,12 +30,12 @@ static int test_torrent_hash(void)
     tr_cryptoConstruct(&a, NULL, true);
 
     check(!tr_cryptoHasTorrentHash(&a));
-    check(tr_cryptoGetTorrentHash(&a) == NULL);
+    check_ptr(tr_cryptoGetTorrentHash(&a), ==, NULL);
 
     tr_cryptoSetTorrentHash(&a, hash);
     check(tr_cryptoHasTorrentHash(&a));
-    check(tr_cryptoGetTorrentHash(&a) != NULL);
-    check(memcmp(tr_cryptoGetTorrentHash(&a), hash, SHA_DIGEST_LENGTH) == 0);
+    check_ptr(tr_cryptoGetTorrentHash(&a), !=, NULL);
+    check_mem(tr_cryptoGetTorrentHash(&a), ==, hash, SHA_DIGEST_LENGTH);
 
     tr_cryptoDestruct(&a);
 
@@ -47,12 +47,12 @@ static int test_torrent_hash(void)
     tr_cryptoConstruct(&a, hash, false);
 
     check(tr_cryptoHasTorrentHash(&a));
-    check(tr_cryptoGetTorrentHash(&a) != NULL);
-    check(memcmp(tr_cryptoGetTorrentHash(&a), hash, SHA_DIGEST_LENGTH) == 0);
+    check_ptr(tr_cryptoGetTorrentHash(&a), !=, NULL);
+    check_mem(tr_cryptoGetTorrentHash(&a), ==, hash, SHA_DIGEST_LENGTH);
 
     tr_cryptoSetTorrentHash(&a, NULL);
     check(!tr_cryptoHasTorrentHash(&a));
-    check(tr_cryptoGetTorrentHash(&a) == NULL);
+    check_ptr(tr_cryptoGetTorrentHash(&a), ==, NULL);
 
     tr_cryptoDestruct(&a);
 
@@ -107,15 +107,13 @@ static int test_sha1(void)
 
     check(tr_sha1(hash, "test", 4, NULL));
     check(tr_sha1_(hash_, "test", 4, NULL));
-    check(memcmp(hash, "\xa9\x4a\x8f\xe5\xcc\xb1\x9b\xa6\x1c\x4c\x08\x73\xd3\x91\xe9\x87\x98\x2f\xbb\xd3",
-        SHA_DIGEST_LENGTH) == 0);
-    check(memcmp(hash, hash_, SHA_DIGEST_LENGTH) == 0);
+    check_mem(hash, ==, "\xa9\x4a\x8f\xe5\xcc\xb1\x9b\xa6\x1c\x4c\x08\x73\xd3\x91\xe9\x87\x98\x2f\xbb\xd3", SHA_DIGEST_LENGTH);
+    check_mem(hash, ==, hash_, SHA_DIGEST_LENGTH);
 
     check(tr_sha1(hash, "1", 1, "22", 2, "333", 3, NULL));
     check(tr_sha1_(hash_, "1", 1, "22", 2, "333", 3, NULL));
-    check(memcmp(hash, "\x1f\x74\x64\x8e\x50\xa6\xa6\x70\x8e\xc5\x4a\xb3\x27\xa1\x63\xd5\x53\x6b\x7c\xed",
-        SHA_DIGEST_LENGTH) == 0);
-    check(memcmp(hash, hash_, SHA_DIGEST_LENGTH) == 0);
+    check_mem(hash, ==, "\x1f\x74\x64\x8e\x50\xa6\xa6\x70\x8e\xc5\x4a\xb3\x27\xa1\x63\xd5\x53\x6b\x7c\xed", SHA_DIGEST_LENGTH);
+    check_mem(hash, ==, hash_, SHA_DIGEST_LENGTH);
 
     return 0;
 }
@@ -147,7 +145,7 @@ static int test_ssha1(void)
         {
             hashes[j] = j % 2 == 0 ? tr_ssha1(phrase) : tr_ssha1_(phrase);
 
-            check(hashes[j] != NULL);
+            check_ptr(hashes[j], !=, NULL);
 
             /* phrase matches each of generated hashes */
             check(tr_ssha1_matches(hashes[j], phrase));
@@ -159,7 +157,10 @@ static int test_ssha1(void)
             /* all hashes are different */
             for (size_t k = 0; k < HASH_COUNT; ++k)
             {
-                check(k == j || strcmp(hashes[j], hashes[k]) != 0);
+                if (k != j)
+                {
+                    check_str(hashes[j], !=, hashes[k]);
+                }
             }
         }
 
@@ -199,8 +200,8 @@ static int test_random(void)
     for (int i = 0; i < 100000; ++i)
     {
         int const val = tr_rand_int(100);
-        check(val >= 0);
-        check(val < 100);
+        check_int(val, >=, 0);
+        check_int(val, <, 100);
     }
 
     return 0;
@@ -255,10 +256,10 @@ static int test_base64(void)
 
     out = tr_base64_encode(NULL, 0, &len);
     check_uint(len, ==, 0);
-    check(out == NULL);
+    check_str(out, ==, NULL);
     out = tr_base64_decode(NULL, 0, &len);
     check_uint(len, ==, 0);
-    check(out == NULL);
+    check_str(out, ==, NULL);
 
 #define MAX_BUF_SIZE 1024
 
@@ -275,7 +276,7 @@ static int test_base64(void)
         check_uint(len, ==, strlen(out));
         in = tr_base64_decode(out, len, &len);
         check_uint(len, ==, i);
-        check(memcmp(in, buf, len) == 0);
+        check_mem(in, ==, buf, len);
         tr_free(in);
         tr_free(out);
 
index e3ddd3c70c0e1f9df722d30565ab7ff87d7046f4..816443f7478365845d64574a3eb1295bb75121d3 100644 (file)
@@ -16,22 +16,22 @@ static int test_error_set(void)
     tr_error* err = NULL;
 
     tr_error_prefix(&err, "error: ");
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
 
     tr_error_set(&err, 1, "error: %s (%d)", "oops", 2);
     check(err != NULL);
     check_int(err->code, ==, 1);
     check_str(err->message, ==, "error: oops (2)");
     tr_error_clear(&err);
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
 
     tr_error_set_literal(&err, 2, "oops");
-    check(err != NULL);
+    check_ptr(err, !=, NULL);
     check_int(err->code, ==, 2);
     check_str(err->message, ==, "oops");
 
     tr_error_prefix(&err, "error: ");
-    check(err != NULL);
+    check_ptr(err, !=, NULL);
     check_int(err->code, ==, 2);
     check_str(err->message, ==, "error: oops");
 
@@ -46,24 +46,24 @@ static int test_error_propagate(void)
     tr_error* err2 = NULL;
 
     tr_error_set_literal(&err, 1, "oops");
-    check(err != NULL);
+    check_ptr(err, !=, NULL);
     check_int(err->code, ==, 1);
     check_str(err->message, ==, "oops");
 
     tr_error_propagate(&err2, &err);
-    check(err2 != NULL);
+    check_ptr(err2, !=, NULL);
     check_int(err2->code, ==, 1);
     check_str(err2->message, ==, "oops");
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
 
     tr_error_propagate_prefixed(&err, &err2, "error: ");
-    check(err != NULL);
+    check_ptr(err, !=, NULL);
     check_int(err->code, ==, 1);
     check_str(err->message, ==, "error: oops");
-    check(err2 == NULL);
+    check_ptr(err2, ==, NULL);
 
     tr_error_propagate(NULL, &err);
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
 
     tr_error_free(err2);
 
index 15752c5330cd8de671c06d81596963eaabea5ce0..f6739ef08483d9db11ceb64845aeb2dabc647a57 100644 (file)
@@ -172,7 +172,7 @@ static int test_get_info(void)
 
     /* Can't get info of non-existent file/directory */
     check(!tr_sys_path_get_info(path1, 0, &info, &err));
-    check(err != NULL);
+    check_ptr(err, !=, NULL);
     tr_error_clear(&err);
 
     t = time(NULL);
@@ -181,19 +181,21 @@ static int test_get_info(void)
     /* Good file info */
     clear_path_info(&info);
     check(tr_sys_path_get_info(path1, 0, &info, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_int(info.type, ==, TR_SYS_PATH_IS_FILE);
     check_uint(info.size, ==, 4);
-    check(info.last_modified_at >= t && info.last_modified_at <= time(NULL));
+    check_int(info.last_modified_at, >=, t);
+    check_int(info.last_modified_at, <=, time(NULL));
 
     /* Good file info (by handle) */
     fd = tr_sys_file_open(path1, TR_SYS_FILE_READ, 0, NULL);
     clear_path_info(&info);
     check(tr_sys_file_get_info(fd, &info, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_int(info.type, ==, TR_SYS_PATH_IS_FILE);
     check_uint(info.size, ==, 4);
-    check(info.last_modified_at >= t && info.last_modified_at <= time(NULL));
+    check_int(info.last_modified_at, >=, t);
+    check_int(info.last_modified_at, <=, time(NULL));
     tr_sys_file_close(fd, NULL);
 
     tr_sys_path_remove(path1, NULL);
@@ -203,17 +205,18 @@ static int test_get_info(void)
     tr_sys_dir_create(path1, 0, 0777, NULL);
     clear_path_info(&info);
     check(tr_sys_path_get_info(path1, 0, &info, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_int(info.type, ==, TR_SYS_PATH_IS_DIRECTORY);
-    check(info.size != (uint64_t)-1);
-    check(info.last_modified_at >= t && info.last_modified_at <= time(NULL));
+    check_uint(info.size, !=, (uint64_t)-1);
+    check_int(info.last_modified_at, >=, t);
+    check_int(info.last_modified_at, <=, time(NULL));
     tr_sys_path_remove(path1, NULL);
 
     if (create_symlink(path1, path2, false))
     {
         /* Can't get info of non-existent file/directory */
         check(!tr_sys_path_get_info(path1, 0, &info, &err));
-        check(err != NULL);
+        check_ptr(err, !=, NULL);
         tr_error_clear(&err);
 
         t = time(NULL);
@@ -222,19 +225,21 @@ static int test_get_info(void)
         /* Good file info */
         clear_path_info(&info);
         check(tr_sys_path_get_info(path1, 0, &info, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
         check_int(info.type, ==, TR_SYS_PATH_IS_FILE);
         check_uint(info.size, ==, 4);
-        check(info.last_modified_at >= t && info.last_modified_at <= time(NULL));
+        check_int(info.last_modified_at, >=, t);
+        check_int(info.last_modified_at, <=, time(NULL));
 
         /* Good file info (by handle) */
         fd = tr_sys_file_open(path1, TR_SYS_FILE_READ, 0, NULL);
         clear_path_info(&info);
         check(tr_sys_file_get_info(fd, &info, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
         check_int(info.type, ==, TR_SYS_PATH_IS_FILE);
         check_uint(info.size, ==, 4);
-        check(info.last_modified_at >= t && info.last_modified_at <= time(NULL));
+        check_int(info.last_modified_at, >=, t);
+        check_int(info.last_modified_at, <=, time(NULL));
         tr_sys_file_close(fd, NULL);
 
         tr_sys_path_remove(path2, NULL);
@@ -244,10 +249,11 @@ static int test_get_info(void)
         tr_sys_dir_create(path2, 0, 0777, NULL);
         clear_path_info(&info);
         check(tr_sys_path_get_info(path1, 0, &info, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
         check_int(info.type, ==, TR_SYS_PATH_IS_DIRECTORY);
-        check(info.size != (uint64_t)-1);
-        check(info.last_modified_at >= t && info.last_modified_at <= time(NULL));
+        check_uint(info.size, !=, (uint64_t)-1);
+        check_int(info.last_modified_at, >=, t);
+        check_int(info.last_modified_at, <=, time(NULL));
 
         tr_sys_path_remove(path2, NULL);
         tr_sys_path_remove(path1, NULL);
@@ -276,19 +282,19 @@ static int test_path_exists(void)
 
     /* Non-existent file does not exist */
     check(!tr_sys_path_exists(path1, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
 
     /* Create file and see that it exists */
     libtest_create_file_with_string_contents(path1, "test");
     check(tr_sys_path_exists(path1, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
 
     tr_sys_path_remove(path1, NULL);
 
     /* Create directory and see that it exists */
     tr_sys_dir_create(path1, 0, 0777, NULL);
     check(tr_sys_path_exists(path1, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
 
     tr_sys_path_remove(path1, NULL);
 
@@ -296,19 +302,19 @@ static int test_path_exists(void)
     {
         /* Non-existent file does not exist (via symlink) */
         check(!tr_sys_path_exists(path1, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
 
         /* Create file and see that it exists (via symlink) */
         libtest_create_file_with_string_contents(path2, "test");
         check(tr_sys_path_exists(path1, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
 
         tr_sys_path_remove(path2, NULL);
 
         /* Create directory and see that it exists (via symlink) */
         tr_sys_dir_create(path2, 0, 0777, NULL);
         check(tr_sys_path_exists(path1, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
 
         tr_sys_path_remove(path2, NULL);
         tr_sys_path_remove(path1, NULL);
@@ -387,45 +393,45 @@ static int test_path_is_same(void)
 
     /* Two non-existent files are not the same */
     check(!tr_sys_path_is_same(path1, path1, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check(!tr_sys_path_is_same(path1, path2, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
 
     /* Two same files are the same */
     libtest_create_file_with_string_contents(path1, "test");
     check(tr_sys_path_is_same(path1, path1, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
 
     /* Existent and non-existent files are not the same */
     check(!tr_sys_path_is_same(path1, path2, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check(!tr_sys_path_is_same(path2, path1, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
 
     /* Two separate files (even with same content) are not the same */
     libtest_create_file_with_string_contents(path2, "test");
     check(!tr_sys_path_is_same(path1, path2, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
 
     tr_sys_path_remove(path1, NULL);
 
     /* Two same directories are the same */
     tr_sys_dir_create(path1, 0, 0777, NULL);
     check(tr_sys_path_is_same(path1, path1, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
 
     /* File and directory are not the same */
     check(!tr_sys_path_is_same(path1, path2, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check(!tr_sys_path_is_same(path2, path1, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
 
     tr_sys_path_remove(path2, NULL);
 
     /* Two separate directories are not the same */
     tr_sys_dir_create(path2, 0, 0777, NULL);
     check(!tr_sys_path_is_same(path1, path2, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
 
     tr_sys_path_remove(path1, NULL);
     tr_sys_path_remove(path2, NULL);
@@ -434,61 +440,61 @@ static int test_path_is_same(void)
     {
         /* Directory and symlink pointing to it are the same */
         check(tr_sys_path_is_same(path1, test_dir, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
         check(tr_sys_path_is_same(test_dir, path1, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
 
         /* Non-existent file and symlink are not the same */
         check(!tr_sys_path_is_same(path1, path2, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
         check(!tr_sys_path_is_same(path2, path1, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
 
         /* Symlinks pointing to different directories are not the same */
         create_symlink(path2, "..", true);
         check(!tr_sys_path_is_same(path1, path2, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
         check(!tr_sys_path_is_same(path2, path1, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
 
         tr_sys_path_remove(path2, NULL);
 
         /* Symlinks pointing to same directory are the same */
         create_symlink(path2, ".", true);
         check(tr_sys_path_is_same(path1, path2, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
 
         tr_sys_path_remove(path2, NULL);
 
         /* Directory and symlink pointing to another directory are not the same */
         tr_sys_dir_create(path2, 0, 0777, NULL);
         check(!tr_sys_path_is_same(path1, path2, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
         check(!tr_sys_path_is_same(path2, path1, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
 
         /* Symlinks pointing to same directory are the same */
         create_symlink(path3, "..", true);
         check(tr_sys_path_is_same(path1, path3, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
 
         tr_sys_path_remove(path1, NULL);
 
         /* File and symlink pointing to directory are not the same */
         libtest_create_file_with_string_contents(path1, "test");
         check(!tr_sys_path_is_same(path1, path3, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
         check(!tr_sys_path_is_same(path3, path1, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
 
         tr_sys_path_remove(path3, NULL);
 
         /* File and symlink pointing to same file are the same */
         create_symlink(path3, path1, false);
         check(tr_sys_path_is_same(path1, path3, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
         check(tr_sys_path_is_same(path3, path1, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
 
         /* Symlinks pointing to non-existent files are not the same */
         tr_sys_path_remove(path1, NULL);
@@ -496,25 +502,25 @@ static int test_path_is_same(void)
         tr_sys_path_remove(path3, NULL);
         create_symlink(path3, "missing", false);
         check(!tr_sys_path_is_same(path1, path3, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
         check(!tr_sys_path_is_same(path3, path1, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
 
         tr_sys_path_remove(path3, NULL);
 
         /* Symlinks pointing to same non-existent file are not the same */
         create_symlink(path3, ".." NATIVE_PATH_SEP "missing", false);
         check(!tr_sys_path_is_same(path1, path3, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
         check(!tr_sys_path_is_same(path3, path1, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
 
         /* Non-existent file and symlink pointing to non-existent file are not the same */
         tr_sys_path_remove(path3, NULL);
         check(!tr_sys_path_is_same(path1, path3, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
         check(!tr_sys_path_is_same(path3, path1, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
 
         tr_sys_path_remove(path2, NULL);
         tr_sys_path_remove(path1, NULL);
@@ -533,19 +539,19 @@ static int test_path_is_same(void)
     {
         /* File and hardlink to it are the same */
         check(tr_sys_path_is_same(path1, path2, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
 
         /* Two hardlinks to the same file are the same */
         create_hardlink(path3, path2);
         check(tr_sys_path_is_same(path2, path3, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
         check(tr_sys_path_is_same(path1, path3, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
 
         tr_sys_path_remove(path2, NULL);
 
         check(tr_sys_path_is_same(path1, path3, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
 
         tr_sys_path_remove(path3, NULL);
 
@@ -553,9 +559,9 @@ static int test_path_is_same(void)
         libtest_create_file_with_string_contents(path3, "test");
         create_hardlink(path2, path3);
         check(!tr_sys_path_is_same(path1, path2, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
         check(!tr_sys_path_is_same(path2, path1, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
 
         tr_sys_path_remove(path3, NULL);
         tr_sys_path_remove(path2, NULL);
@@ -568,7 +574,7 @@ static int test_path_is_same(void)
     if (create_symlink(path2, path1, false) && create_hardlink(path3, path1))
     {
         check(tr_sys_path_is_same(path2, path3, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
     }
     else
     {
@@ -604,8 +610,8 @@ static int test_path_resolve(void)
         char* tmp;
 
         tmp = tr_sys_path_resolve(path2, &err);
-        check(tmp != NULL);
-        check(err == NULL);
+        check_str(tmp, !=, NULL);
+        check_ptr(err, ==, NULL);
         check(path_contains_no_symlinks(tmp));
         tr_free(tmp);
 
@@ -613,8 +619,8 @@ static int test_path_resolve(void)
         tr_sys_dir_create(path1, 0, 0755, NULL);
 
         tmp = tr_sys_path_resolve(path2, &err);
-        check(tmp != NULL);
-        check(err == NULL);
+        check_str(tmp, !=, NULL);
+        check_ptr(err, ==, NULL);
         check(path_contains_no_symlinks(tmp));
         tr_free(tmp);
     }
@@ -648,15 +654,15 @@ static int test_path_xname(struct xname_test_data const* data, size_t data_size,
 
         if (data[i].output != NULL)
         {
-            check(name != NULL);
-            check(err == NULL);
+            check_str(name, !=, NULL);
+            check_ptr(err, ==, NULL);
             check_str(name, ==, data[i].output);
             tr_free(name);
         }
         else
         {
-            check(name == NULL);
-            check(err != NULL);
+            check_str(name, ==, NULL);
+            check_ptr(err, !=, NULL);
             tr_error_clear(&err);
         }
     }
@@ -802,43 +808,43 @@ static int test_path_rename(void)
     check(tr_sys_path_rename(path1, path2, &err));
     check(!tr_sys_path_exists(path1, NULL));
     check(tr_sys_path_exists(path2, NULL));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
 
     /* Backward rename works */
     check(tr_sys_path_rename(path2, path1, &err));
     check(tr_sys_path_exists(path1, NULL));
     check(!tr_sys_path_exists(path2, NULL));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
 
     /* Another backward rename [of non-existent file] does not work */
     check(!tr_sys_path_rename(path2, path1, &err));
-    check(err != NULL);
+    check_ptr(err, !=, NULL);
     tr_error_clear(&err);
 
     /* Rename to file which couldn't be created does not work */
     check(!tr_sys_path_rename(path1, path3, &err));
-    check(err != NULL);
+    check_ptr(err, !=, NULL);
     tr_error_clear(&err);
 
     /* Rename of non-existent file does not work */
     check(!tr_sys_path_rename(path3, path2, &err));
-    check(err != NULL);
+    check_ptr(err, !=, NULL);
     tr_error_clear(&err);
 
     libtest_create_file_with_string_contents(path2, "test");
 
     /* Renaming file does overwrite existing file */
     check(tr_sys_path_rename(path2, path1, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
 
     tr_sys_dir_create(path2, 0, 0777, NULL);
 
     /* Renaming file does not overwrite existing directory, and vice versa */
     check(!tr_sys_path_rename(path1, path2, &err));
-    check(err != NULL);
+    check_ptr(err, !=, NULL);
     tr_error_clear(&err);
     check(!tr_sys_path_rename(path2, path1, &err));
-    check(err != NULL);
+    check_ptr(err, !=, NULL);
     tr_error_clear(&err);
 
     tr_sys_path_remove(path2, NULL);
@@ -855,7 +861,7 @@ static int test_path_rename(void)
 
         /* Rename of symlink works, files stay the same */
         check(tr_sys_path_rename(path2, path3, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
         check(!tr_sys_path_exists(path2, NULL));
         check(tr_sys_path_exists(path3, NULL));
         check(tr_sys_path_is_same(path1, path3, NULL));
@@ -876,7 +882,7 @@ static int test_path_rename(void)
 
         /* Rename of hardlink works, files stay the same */
         check(tr_sys_path_rename(path2, path3, &err));
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
         check(!tr_sys_path_exists(path2, NULL));
         check(tr_sys_path_exists(path3, NULL));
         check(tr_sys_path_is_same(path1, path3, NULL));
@@ -913,7 +919,7 @@ static int test_path_remove(void)
     /* Can't remove non-existent file/directory */
     check(!tr_sys_path_exists(path1, NULL));
     check(!tr_sys_path_remove(path1, &err));
-    check(err != NULL);
+    check_ptr(err, !=, NULL);
     check(!tr_sys_path_exists(path1, NULL));
     tr_error_clear(&err);
 
@@ -921,14 +927,14 @@ static int test_path_remove(void)
     libtest_create_file_with_string_contents(path1, "test");
     check(tr_sys_path_exists(path1, NULL));
     check(tr_sys_path_remove(path1, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check(!tr_sys_path_exists(path1, NULL));
 
     /* Removing empty directory works */
     tr_sys_dir_create(path1, 0, 0777, NULL);
     check(tr_sys_path_exists(path1, NULL));
     check(tr_sys_path_remove(path1, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check(!tr_sys_path_exists(path1, NULL));
 
     /* Removing non-empty directory fails */
@@ -937,7 +943,7 @@ static int test_path_remove(void)
     check(tr_sys_path_exists(path2, NULL));
     check(tr_sys_path_exists(path3, NULL));
     check(!tr_sys_path_remove(path2, &err));
-    check(err != NULL);
+    check_ptr(err, !=, NULL);
     check(tr_sys_path_exists(path2, NULL));
     check(tr_sys_path_exists(path3, NULL));
     tr_error_clear(&err);
@@ -967,11 +973,11 @@ static int test_file_open(void)
     /* Can't open non-existent file */
     check(!tr_sys_path_exists(path1, NULL));
     check(tr_sys_file_open(path1, TR_SYS_FILE_READ, 0600, &err) == TR_BAD_SYS_FILE);
-    check(err != NULL);
+    check_ptr(err, !=, NULL);
     check(!tr_sys_path_exists(path1, NULL));
     tr_error_clear(&err);
     check(tr_sys_file_open(path1, TR_SYS_FILE_WRITE, 0600, &err) == TR_BAD_SYS_FILE);
-    check(err != NULL);
+    check_ptr(err, !=, NULL);
     check(!tr_sys_path_exists(path1, NULL));
     tr_error_clear(&err);
 
@@ -980,19 +986,19 @@ static int test_file_open(void)
 #ifdef _WIN32
     /* This works on *NIX */
     check(tr_sys_file_open(path1, TR_SYS_FILE_READ, 0600, &err) == TR_BAD_SYS_FILE);
-    check(err != NULL);
+    check_ptr(err, !=, NULL);
     tr_error_clear(&err);
 #endif
     check(tr_sys_file_open(path1, TR_SYS_FILE_WRITE, 0600, &err) == TR_BAD_SYS_FILE);
-    check(err != NULL);
+    check_ptr(err, !=, NULL);
     tr_error_clear(&err);
 
     tr_sys_path_remove(path1, NULL);
 
     /* Can create non-existent file */
     fd = tr_sys_file_open(path1, TR_SYS_FILE_WRITE | TR_SYS_FILE_CREATE, 0640, &err);
-    check(fd != TR_BAD_SYS_FILE);
-    check(err == NULL);
+    check_int(fd, !=, TR_BAD_SYS_FILE);
+    check_ptr(err, ==, NULL);
     tr_sys_file_close(fd, NULL);
     check(tr_sys_path_exists(path1, NULL));
     check(validate_permissions(path1, 0640));
@@ -1000,12 +1006,12 @@ static int test_file_open(void)
     /* Can open existing file */
     check(tr_sys_path_exists(path1, NULL));
     fd = tr_sys_file_open(path1, TR_SYS_FILE_READ, 0600, &err);
-    check(fd != TR_BAD_SYS_FILE);
-    check(err == NULL);
+    check_int(fd, !=, TR_BAD_SYS_FILE);
+    check_ptr(err, ==, NULL);
     tr_sys_file_close(fd, NULL);
     fd = tr_sys_file_open(path1, TR_SYS_FILE_WRITE, 0600, &err);
-    check(fd != TR_BAD_SYS_FILE);
-    check(err == NULL);
+    check_int(fd, !=, TR_BAD_SYS_FILE);
+    check_ptr(err, ==, NULL);
     tr_sys_file_close(fd, NULL);
 
     tr_sys_path_remove(path1, NULL);
@@ -1013,8 +1019,8 @@ static int test_file_open(void)
 
     /* Can't create new file if it already exists */
     fd = tr_sys_file_open(path1, TR_SYS_FILE_WRITE | TR_SYS_FILE_CREATE_NEW, 0640, &err);
-    check(fd == TR_BAD_SYS_FILE);
-    check(err != NULL);
+    check_int(fd, ==, TR_BAD_SYS_FILE);
+    check_ptr(err, !=, NULL);
     tr_error_clear(&err);
     tr_sys_path_get_info(path1, TR_SYS_PATH_NO_FOLLOW, &info, NULL);
     check_uint(info.size, ==, 4);
@@ -1023,8 +1029,8 @@ static int test_file_open(void)
     tr_sys_path_get_info(path1, TR_SYS_PATH_NO_FOLLOW, &info, NULL);
     check_uint(info.size, ==, 4);
     fd = tr_sys_file_open(path1, TR_SYS_FILE_WRITE | TR_SYS_FILE_APPEND, 0600, &err);
-    check(fd != TR_BAD_SYS_FILE);
-    check(err == NULL);
+    check_int(fd, !=, TR_BAD_SYS_FILE);
+    check_ptr(err, ==, NULL);
     tr_sys_file_write(fd, "s", 1, NULL, NULL); /* On *NIX, pointer is positioned on each write but not initially */
     tr_sys_file_seek(fd, 0, TR_SEEK_CUR, &n, NULL);
     check_uint(n, ==, 5);
@@ -1034,8 +1040,8 @@ static int test_file_open(void)
     tr_sys_path_get_info(path1, TR_SYS_PATH_NO_FOLLOW, &info, NULL);
     check_uint(info.size, ==, 5);
     fd = tr_sys_file_open(path1, TR_SYS_FILE_WRITE | TR_SYS_FILE_TRUNCATE, 0600, &err);
-    check(fd != TR_BAD_SYS_FILE);
-    check(err == NULL);
+    check_int(fd, !=, TR_BAD_SYS_FILE);
+    check_ptr(err, ==, NULL);
     tr_sys_file_get_info(fd, &info, NULL);
     check_uint(info.size, ==, 0);
     tr_sys_file_close(fd, NULL);
@@ -1066,72 +1072,72 @@ static int test_file_read_write_seek(void)
     fd = tr_sys_file_open(path1, TR_SYS_FILE_READ | TR_SYS_FILE_WRITE | TR_SYS_FILE_CREATE, 0600, NULL);
 
     check(tr_sys_file_seek(fd, 0, TR_SEEK_CUR, &n, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_uint(n, ==, 0);
 
     check(tr_sys_file_write(fd, "test", 4, &n, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_uint(n, ==, 4);
 
     check(tr_sys_file_seek(fd, 0, TR_SEEK_CUR, &n, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_uint(n, ==, 4);
 
     check(tr_sys_file_seek(fd, 0, TR_SEEK_SET, &n, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_uint(n, ==, 0);
 
     check(tr_sys_file_read(fd, buf, sizeof(buf), &n, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_uint(n, ==, 4);
 
-    check_int(memcmp(buf, "test", 4), ==, 0);
+    check_mem(buf, ==, "test", 4);
 
     check(tr_sys_file_seek(fd, -3, TR_SEEK_CUR, &n, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_uint(n, ==, 1);
 
     check(tr_sys_file_write(fd, "E", 1, &n, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_uint(n, ==, 1);
 
     check(tr_sys_file_seek(fd, -2, TR_SEEK_CUR, &n, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_uint(n, ==, 0);
 
     check(tr_sys_file_read(fd, buf, sizeof(buf), &n, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_uint(n, ==, 4);
 
-    check_int(memcmp(buf, "tEst", 4), ==, 0);
+    check_mem(buf, ==, "tEst", 4);
 
     check(tr_sys_file_seek(fd, 0, TR_SEEK_END, &n, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_uint(n, ==, 4);
 
     check(tr_sys_file_write(fd, " ok", 3, &n, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_uint(n, ==, 3);
 
     check(tr_sys_file_seek(fd, 0, TR_SEEK_SET, &n, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_uint(n, ==, 0);
 
     check(tr_sys_file_read(fd, buf, sizeof(buf), &n, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_uint(n, ==, 7);
 
-    check_int(memcmp(buf, "tEst ok", 7), ==, 0);
+    check_mem(buf, ==, "tEst ok", 7);
 
     check(tr_sys_file_write_at(fd, "-", 1, 4, &n, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_uint(n, ==, 1);
 
     check(tr_sys_file_read_at(fd, buf, 5, 2, &n, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_uint(n, ==, 5);
 
-    check_int(memcmp(buf, "st-ok", 5), ==, 0);
+    check_mem(buf, ==, "st-ok", 5);
 
     tr_sys_file_close(fd, NULL);
 
@@ -1156,22 +1162,22 @@ static int test_file_truncate(void)
     fd = tr_sys_file_open(path1, TR_SYS_FILE_WRITE | TR_SYS_FILE_CREATE, 0600, NULL);
 
     check(tr_sys_file_truncate(fd, 10, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     tr_sys_file_get_info(fd, &info, NULL);
     check_uint(info.size, ==, 10);
 
     check(tr_sys_file_truncate(fd, 20, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     tr_sys_file_get_info(fd, &info, NULL);
     check_uint(info.size, ==, 20);
 
     check(tr_sys_file_truncate(fd, 0, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     tr_sys_file_get_info(fd, &info, NULL);
     check_uint(info.size, ==, 0);
 
     check(tr_sys_file_truncate(fd, 50, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
 
     tr_sys_file_close(fd, NULL);
 
@@ -1181,7 +1187,7 @@ static int test_file_truncate(void)
     fd = tr_sys_file_open(path1, TR_SYS_FILE_WRITE | TR_SYS_FILE_CREATE, 0600, NULL);
 
     check(tr_sys_file_truncate(fd, 25, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
 
     tr_sys_file_close(fd, NULL);
 
@@ -1210,13 +1216,13 @@ static int test_file_preallocate(void)
 
     if (tr_sys_file_preallocate(fd, 50, 0, &err))
     {
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
         tr_sys_file_get_info(fd, &info, NULL);
         check_uint(info.size, ==, 50);
     }
     else
     {
-        check(err != NULL);
+        check_ptr(err, !=, NULL);
         fprintf(stderr, "WARNING: [%s] unable to preallocate file (full): %s (%d)\n", __FUNCTION__, err->message, err->code);
         tr_error_clear(&err);
     }
@@ -1229,13 +1235,13 @@ static int test_file_preallocate(void)
 
     if (tr_sys_file_preallocate(fd, 500 * 1024 * 1024, TR_SYS_FILE_PREALLOC_SPARSE, &err))
     {
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
         tr_sys_file_get_info(fd, &info, NULL);
         check_uint(info.size, ==, 500 * 1024 * 1024);
     }
     else
     {
-        check(err != NULL);
+        check_ptr(err, !=, NULL);
         fprintf(stderr, "WARNING: [%s] unable to preallocate file (sparse): %s (%d)\n", __FUNCTION__, err->message, err->code);
         tr_error_clear(&err);
     }
@@ -1265,21 +1271,21 @@ static int test_file_map(void)
     fd = tr_sys_file_open(path1, TR_SYS_FILE_READ | TR_SYS_FILE_WRITE, 0600, NULL);
 
     view = tr_sys_file_map_for_reading(fd, 0, 4, &err);
-    check(view != NULL);
-    check(err == NULL);
+    check_ptr(view, !=, NULL);
+    check_ptr(err, ==, NULL);
 
-    check_int(memcmp(view, "test", 4), ==, 0);
+    check_mem(view, ==, "test", 4);
 
 #ifdef HAVE_UNIFIED_BUFFER_CACHE
 
     tr_sys_file_write_at(fd, "E", 1, 1, NULL, NULL);
 
-    check_int(memcmp(view, "tEst", 4), ==, 0);
+    check_mem(view, ==, "tEst", 4);
 
 #endif
 
     check(tr_sys_file_unmap(view, 4, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
 
     tr_sys_file_close(fd, NULL);
 
@@ -1306,31 +1312,31 @@ static int test_file_utilities(void)
     fd = tr_sys_file_open(path1, TR_SYS_FILE_READ, 0, NULL);
 
     check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_str(buffer, ==, "a");
     check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_str(buffer, ==, "bc");
     check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_str(buffer, ==, "def");
     check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_str(buffer, ==, "ghij");
     check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_str(buffer, ==, "");
     check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_str(buffer, ==, "");
     check(tr_sys_file_read_line(fd, buffer, 4, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_str(buffer, ==, "klmn");
     check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_str(buffer, ==, "o");
     check(!tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_str(buffer, ==, "o"); /* on EOF, buffer stays unchanged */
 
     tr_sys_file_close(fd, NULL);
@@ -1338,45 +1344,45 @@ static int test_file_utilities(void)
     fd = tr_sys_file_open(path1, TR_SYS_FILE_READ | TR_SYS_FILE_WRITE | TR_SYS_FILE_TRUNCATE, 0, NULL);
 
     check(tr_sys_file_write_line(fd, "p", &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check(tr_sys_file_write_line(fd, "", &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check(tr_sys_file_write_line(fd, "qr", &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check(tr_sys_file_write_fmt(fd, "s%cu\r\n", &err, 't'));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check(tr_sys_file_write_line(fd, "", &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check(tr_sys_file_write_line(fd, "", &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check(tr_sys_file_write_fmt(fd, "v%sy%d", &err, "wx", 2));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
 
     tr_sys_file_seek(fd, 0, TR_SEEK_SET, NULL, NULL);
 
     check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_str(buffer, ==, "p");
     check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_str(buffer, ==, "");
     check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_str(buffer, ==, "qr");
     check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_str(buffer, ==, "stu");
     check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_str(buffer, ==, "");
     check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_str(buffer, ==, "");
     check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_str(buffer, ==, "vwxy2");
     check(!tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check_str(buffer, ==, "vwxy2"); /* on EOF, buffer stays unchanged */
 
     tr_sys_file_close(fd, NULL);
@@ -1401,7 +1407,7 @@ static int test_dir_create(void)
 
     /* Can create directory which has parent */
     check(tr_sys_dir_create(path1, 0, 0700, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check(tr_sys_path_exists(path1, NULL));
     check(validate_permissions(path1, 0700));
 
@@ -1410,23 +1416,23 @@ static int test_dir_create(void)
 
     /* Can't create directory where file already exists */
     check(!tr_sys_dir_create(path1, 0, 0700, &err));
-    check(err != NULL);
+    check_ptr(err, !=, NULL);
     tr_error_clear(&err);
     check(!tr_sys_dir_create(path1, TR_SYS_DIR_CREATE_PARENTS, 0700, &err));
-    check(err != NULL);
+    check_ptr(err, !=, NULL);
     tr_error_clear(&err);
 
     tr_sys_path_remove(path1, NULL);
 
     /* Can't create directory which has no parent */
     check(!tr_sys_dir_create(path2, 0, 0700, &err));
-    check(err != NULL);
+    check_ptr(err, !=, NULL);
     check(!tr_sys_path_exists(path2, NULL));
     tr_error_clear(&err);
 
     /* Can create directory with parent directories */
     check(tr_sys_dir_create(path2, TR_SYS_DIR_CREATE_PARENTS, 0751, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check(tr_sys_path_exists(path1, NULL));
     check(tr_sys_path_exists(path2, NULL));
     check(validate_permissions(path1, 0751));
@@ -1434,9 +1440,9 @@ static int test_dir_create(void)
 
     /* Can create existing directory (no-op) */
     check(tr_sys_dir_create(path1, 0, 0700, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
     check(tr_sys_dir_create(path1, TR_SYS_DIR_CREATE_PARENTS, 0700, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
 
     tr_sys_path_remove(path2, NULL);
     tr_sys_path_remove(path1, NULL);
@@ -1457,12 +1463,12 @@ static int test_dir_read_impl(char const* path, bool* have1, bool* have2)
     *have1 = *have2 = false;
 
     dd = tr_sys_dir_open(path, &err);
-    check(dd != TR_BAD_SYS_DIR);
-    check(err == NULL);
+    check_ptr(dd, !=, TR_BAD_SYS_DIR);
+    check_ptr(err, ==, NULL);
 
     while ((name = tr_sys_dir_read_name(dd, &err)) != NULL)
     {
-        check(err == NULL);
+        check_ptr(err, ==, NULL);
 
         if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0)
         {
@@ -1483,10 +1489,10 @@ static int test_dir_read_impl(char const* path, bool* have1, bool* have2)
         }
     }
 
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
 
     check(tr_sys_dir_close(dd, &err));
-    check(err == NULL);
+    check_ptr(err, ==, NULL);
 
     return 0;
 }
index 960aab5a8a60902ad962c9d71f2d658bcc0acfcb..a8cc4cc9fbc617f6b470f0ccd824fc8ae64c6e18 100644 (file)
@@ -78,7 +78,7 @@ static int test_utf8(void)
     tr_quark const key = tr_quark_new("key", 3);
 
     err = tr_variantFromJson(&top, in, strlen(in));
-    check(err == 0);
+    check_int(err, ==, 0);
     check(tr_variantIsDict(&top));
     check(tr_variantDictFindStr(&top, key, &str, NULL));
     check_str(str, ==, "Letöltések");
@@ -90,7 +90,7 @@ static int test_utf8(void)
 
     in = "{ \"key\": \"\\u005C\" }";
     err = tr_variantFromJson(&top, in, strlen(in));
-    check(err == 0);
+    check_int(err, ==, 0);
     check(tr_variantIsDict(&top));
     check(tr_variantDictFindStr(&top, key, &str, NULL));
     check_str(str, ==, "\\");
@@ -110,7 +110,7 @@ static int test_utf8(void)
      */
     in = "{ \"key\": \"Let\\u00f6lt\\u00e9sek\" }";
     err = tr_variantFromJson(&top, in, strlen(in));
-    check(err == 0);
+    check_int(err, ==, 0);
     check(tr_variantIsDict(&top));
     check(tr_variantDictFindStr(&top, key, &str, NULL));
     check_str(str, ==, "Letöltések");
@@ -121,11 +121,11 @@ static int test_utf8(void)
         tr_variantFree(&top);
     }
 
-    check(json != NULL);
-    check(strstr(json, "\\u00f6") != NULL);
-    check(strstr(json, "\\u00e9") != NULL);
+    check_ptr(json, !=, NULL);
+    check_str(strstr(json, "\\u00f6"), !=, NULL);
+    check_str(strstr(json, "\\u00e9"), !=, NULL);
     err = tr_variantFromJson(&top, json, strlen(json));
-    check(err == 0);
+    check_int(err, ==, 0);
     check(tr_variantIsDict(&top));
     check(tr_variantDictFindStr(&top, key, &str, NULL));
     check_str(str, ==, "Letöltések");
@@ -164,20 +164,20 @@ static int test1(void)
     int64_t i;
     int const err = tr_variantFromJson(&top, in, strlen(in));
 
-    check(err == 0);
+    check_int(err, ==, 0);
     check(tr_variantIsDict(&top));
-    check((headers = tr_variantDictFind(&top, tr_quark_new("headers", 7))) != NULL);
+    check_ptr((headers = tr_variantDictFind(&top, tr_quark_new("headers", 7))), !=, NULL);
     check(tr_variantIsDict(headers));
     check(tr_variantDictFindStr(headers, tr_quark_new("type", 4), &str, NULL));
     check_str(str, ==, "request");
     check(tr_variantDictFindInt(headers, TR_KEY_tag, &i));
     check_int(i, ==, 666);
-    check((body = tr_variantDictFind(&top, tr_quark_new("body", 4))) != NULL);
+    check_ptr((body = tr_variantDictFind(&top, tr_quark_new("body", 4))), !=, NULL);
     check(tr_variantDictFindStr(body, TR_KEY_name, &str, NULL));
     check_str(str, ==, "torrent-info");
-    check((args = tr_variantDictFind(body, tr_quark_new("arguments", 9))) != NULL);
+    check_ptr((args = tr_variantDictFind(body, tr_quark_new("arguments", 9))), !=, NULL);
     check(tr_variantIsDict(args));
-    check((ids = tr_variantDictFind(args, TR_KEY_ids)) != NULL);
+    check_ptr((ids = tr_variantDictFind(args, TR_KEY_ids)), !=, NULL);
     check(tr_variantIsList(ids));
     check_uint(tr_variantListSize(ids), ==, 2);
     check(tr_variantGetInt(tr_variantListChild(ids, 0), &i));
@@ -198,7 +198,7 @@ static int test2(void)
     top.type = 0;
     err = tr_variantFromJson(&top, in, strlen(in));
 
-    check(err != 0);
+    check_int(err, !=, 0);
     check(!tr_variantIsDict(&top));
 
     return 0;
@@ -216,7 +216,7 @@ static int test3(void)
     char const* str;
 
     int const err = tr_variantFromJson(&top, in, strlen(in));
-    check(err == 0);
+    check_int(err, ==, 0);
     check(tr_variantDictFindStr(&top, TR_KEY_errorString, &str, NULL));
     check_str(str, ==, "torrent not registered with this tracker 6UHsVW'*C");
 
index 3eddec8b0a268ccdd7720d49cb9bc953e459e504..d464ba1591663ae772d87e5ca1639952adab683a 100644 (file)
@@ -16,7 +16,7 @@ static int test1(void)
 {
     char const* uri;
     tr_magnet_info* info;
-    int const dec[] =
+    uint8_t const dec[] =
     {
         210, 53, 64, 16, 163, 202, 74, 222, 91, 116,
         39, 187, 9, 58, 98, 163, 137, 159, 243, 129
@@ -30,18 +30,14 @@ static int test1(void)
         "&tr=http%3A%2F%2Ftracker.opentracker.org%2Fannounce"
         "&ws=http%3A%2F%2Fserver.webseed.org%2Fpath%2Fto%2Ffile";
     info = tr_magnetParse(uri);
-    check(info != NULL);
+    check_ptr(info, !=, NULL);
     check_int(info->trackerCount, ==, 2);
     check_str(info->trackers[0], ==, "http://tracker.openbittorrent.com/announce");
     check_str(info->trackers[1], ==, "http://tracker.opentracker.org/announce");
     check_int(info->webseedCount, ==, 1);
     check_str(info->webseeds[0], ==, "http://server.webseed.org/path/to/file");
     check_str(info->displayName, ==, "Display Name");
-
-    for (int i = 0; i < 20; ++i)
-    {
-        check(info->hash[i] == dec[i]);
-    }
+    check_mem(info->hash, ==, dec, 20);
 
     tr_magnetFree(info);
     info = NULL;
@@ -62,11 +58,7 @@ static int test1(void)
     check_int(info->webseedCount, ==, 1);
     check_str(info->webseeds[0], ==, "http://server.webseed.org/path/to/file");
     check_str(info->displayName, ==, "Display Name");
-
-    for (int i = 0; i < 20; ++i)
-    {
-        check(info->hash[i] == dec[i]);
-    }
+    check_mem(info->hash, ==, dec, 20);
 
     tr_magnetFree(info);
     info = NULL;
index a64cf94de5789b757bf5c8953570d01eadb83086..610137813e994f55d713244d781f2a07e4b8dc88 100644 (file)
@@ -46,7 +46,7 @@ static int test_single_file_impl(tr_tracker_info const* trackers, size_t const t
     /* have tr_makeMetaInfo() build the .torrent file */
     torrent_file = tr_strdup_printf("%s.torrent", input_file);
     tr_makeMetaInfo(builder, torrent_file, trackers, trackerCount, comment, isPrivate);
-    check(isPrivate == builder->isPrivate);
+    check_bool(isPrivate, ==, builder->isPrivate);
     check_str(builder->outputFile, ==, torrent_file);
     check_str(builder->comment, ==, comment);
     check_int(builder->trackerCount, ==, trackerCount);
@@ -163,7 +163,7 @@ static int test_single_directory_impl(tr_tracker_info const* trackers, size_t co
     /* call tr_makeMetaInfo() to build the .torrent file */
     torrent_file = tr_strdup_printf("%s.torrent", top);
     tr_makeMetaInfo(builder, torrent_file, trackers, trackerCount, comment, isPrivate);
-    check(isPrivate == builder->isPrivate);
+    check_bool(isPrivate, ==, builder->isPrivate);
     check_str(builder->outputFile, ==, torrent_file);
     check_str(builder->comment, ==, comment);
     check_int(builder->trackerCount, ==, trackerCount);
index c4b51654a05fc084581e61bbb6dea7f09947e17d..8b3bd1ba1a62891819946bf4b7d5f8badd225b35 100644 (file)
@@ -85,7 +85,7 @@ static int test_incomplete_dir_impl(char const* incomplete_dir, char const* down
        the test zero_torrent will be missing its first piece */
     tor = libttest_zero_torrent_init(session);
     libttest_zero_torrent_populate(tor, false);
-    check(tr_torrentStat(tor)->leftUntilDone == tor->info.pieceSize);
+    check_uint(tr_torrentStat(tor)->leftUntilDone, ==, tor->info.pieceSize);
     check_file_location(tor, 0, tr_strdup_printf("%s/%s.part", incomplete_dir, tor->info.files[0].name));
     check_file_location(tor, 1, tr_buildPath(incomplete_dir, tor->info.files[1].name, NULL));
     check_uint(tr_torrentStat(tor)->leftUntilDone, ==, tor->info.pieceSize);
index 864429a9ffc388dda6120123c259b79c7528bd4f..d204f4239d7caa06471004c5d3a70b8938523a0c 100644 (file)
@@ -6,7 +6,9 @@
  *
  */
 
+#include <memory.h>
 #include <stdio.h>
+
 #include "transmission.h"
 #include "peer-msgs.h"
 #include "utils.h"
@@ -25,30 +27,19 @@ int main(void)
     tr_piece_index_t pieces[] = { 1059, 431, 808, 1217, 287, 376, 1188, 353, 508 };
     tr_piece_index_t buf[16];
 
-    for (uint32_t i = 0; i < SHA_DIGEST_LENGTH; ++i)
-    {
-        infohash[i] = 0xaa;
-    }
+    memset(infohash, 0xaa, SHA_DIGEST_LENGTH);
 
     tr_address_from_string(&addr, "80.4.4.200");
 
     numwant = 7;
     numgot = tr_generateAllowedSet(buf, numwant, pieceCount, infohash, &addr);
-    check(numgot == numwant);
-
-    for (uint32_t i = 0; i < numgot; ++i)
-    {
-        check(buf[i] == pieces[i]);
-    }
+    check_uint(numgot, ==, numwant);
+    check_mem(buf, ==, pieces, numgot);
 
     numwant = 9;
     numgot = tr_generateAllowedSet(buf, numwant, pieceCount, infohash, &addr);
-    check(numgot == numwant);
-
-    for (uint32_t i = 0; i < numgot; ++i)
-    {
-        check(buf[i] == pieces[i]);
-    }
+    check_uint(numgot, ==, numwant);
+    check_mem(buf, ==, pieces, numgot);
 
 #endif
 
index e26236513ba8b1d9c9c0e5b8e80a98f97a05a392..1c9ddde9c95479c8a4c225b94150c161f0e0005f 100644 (file)
@@ -36,7 +36,7 @@ static int test_static_quarks(void)
         str1 = tr_quark_get_string((tr_quark)i, &len1);
         str2 = tr_quark_get_string((tr_quark)(i + 1), &len2);
 
-        check(strcmp(str1, str2) < 0);
+        check_str(str1, <, str2);
     }
 
     tr_quark const q = tr_quark_new(NULL, TR_BAD_SIZE);
index 9184ebb08c53a1ac1cbf7c7711fbf72e51026d50..02436885704e29110613462765ba6a12e9948777 100644 (file)
@@ -200,7 +200,7 @@ static int test_single_filename_torrent(void)
     check(tor->info.files[0].is_renamed); /* confirm the file's 'renamed' flag is set */
     check_str(tr_torrentName(tor), ==, "foobar"); /* confirm the torrent's name is now 'foobar' */
     check_str(tor->info.files[0].name, ==, "foobar"); /* confirm the file's name is now 'foobar' in our struct */
-    check(strstr(tor->info.torrent, "foobar") == NULL); /* confirm the name in the .torrent file hasn't changed */
+    check_str(strstr(tor->info.torrent, "foobar"), ==, NULL); /* confirm the name in the .torrent file hasn't changed */
     tmpstr = tr_buildPath(tor->currentDir, "foobar", NULL);
     check(tr_sys_path_exists(tmpstr, NULL)); /* confirm the file's name is now 'foobar' on the disk */
     tr_free(tmpstr);
@@ -211,7 +211,7 @@ static int test_single_filename_torrent(void)
     libttest_sync();
     loaded = tr_torrentLoadResume(tor, ~0, ctor);
     check_str(tr_torrentName(tor), ==, "foobar");
-    check((loaded & TR_FR_NAME) != 0);
+    check_uint((loaded & TR_FR_NAME), !=, 0);
 
     /***
     ****  ...and rename it back again
@@ -362,7 +362,7 @@ static int test_multifile_torrent(void)
     tr_free(files[1].name);
     tor->info.files[1].name = tr_strdup("gabba gabba hey");
     loaded = tr_torrentLoadResume(tor, ~0, ctor);
-    check((loaded & TR_FR_FILENAMES) != 0);
+    check_uint((loaded & TR_FR_FILENAMES), !=, 0);
     check_str(files[0].name, ==, expected_files[0]);
     check_str(files[1].name, ==, "Felidae/Felinae/Felis/placeholder/Kyphi");
     check_str(files[2].name, ==, "Felidae/Felinae/Felis/placeholder/Saffron");
@@ -388,11 +388,11 @@ static int test_multifile_torrent(void)
 
     /* remove the directory Felidae/Felinae/Felis/catus */
     str = tr_torrentFindFile(tor, 1);
-    check(str != NULL);
+    check_str(str, !=, NULL);
     tr_sys_path_remove(str, NULL);
     tr_free(str);
     str = tr_torrentFindFile(tor, 2);
-    check(str != NULL);
+    check_str(str, !=, NULL);
     tr_sys_path_remove(str, NULL);
     tmp = tr_sys_path_dirname(str, NULL);
     tr_sys_path_remove(tmp, NULL);
index 712d007449a4c45c06d1a6e609def7e0758b4845..33b219b10ea38f617a2d518ee2e6b70ab96421ca 100644 (file)
@@ -34,7 +34,7 @@ static int test_list(void)
 
     tr_rpc_parse_list_str(&top, "6,7", TR_BAD_SIZE);
     check(tr_variantIsList(&top));
-    check(tr_variantListSize(&top) == 2);
+    check_uint(tr_variantListSize(&top), ==, 2);
     check(tr_variantGetInt(tr_variantListChild(&top, 0), &i));
     check_int(i, ==, 6);
     check(tr_variantGetInt(tr_variantListChild(&top, 1), &i));
@@ -50,7 +50,7 @@ static int test_list(void)
 
     tr_rpc_parse_list_str(&top, "1,3-5", TR_BAD_SIZE);
     check(tr_variantIsList(&top));
-    check(tr_variantListSize(&top) == 4);
+    check_uint(tr_variantListSize(&top), ==, 4);
     check(tr_variantGetInt(tr_variantListChild(&top, 0), &i));
     check_int(i, ==, 1);
     check(tr_variantGetInt(tr_variantListChild(&top, 1), &i));
@@ -84,7 +84,7 @@ static int test_session_get_and_set(void)
 
     session = libttest_session_init(NULL);
     tor = libttest_zero_torrent_init(session);
-    check(tor != NULL);
+    check_ptr(tor, !=, NULL);
 
     tr_variantInitDict(&request, 1);
     tr_variantDictAddStr(&request, TR_KEY_method, "session-get");
@@ -93,55 +93,55 @@ static int test_session_get_and_set(void)
 
     check(tr_variantIsDict(&response));
     check(tr_variantDictFindDict(&response, TR_KEY_arguments, &args));
-    check(tr_variantDictFind(args, TR_KEY_alt_speed_down) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_alt_speed_enabled) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_alt_speed_time_begin) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_alt_speed_time_day) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_alt_speed_time_enabled) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_alt_speed_time_end) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_alt_speed_up) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_blocklist_enabled) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_blocklist_size) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_blocklist_url) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_cache_size_mb) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_config_dir) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_dht_enabled) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_download_dir) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_download_dir_free_space) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_download_queue_enabled) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_download_queue_size) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_encryption) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_idle_seeding_limit) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_idle_seeding_limit_enabled) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_incomplete_dir) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_incomplete_dir_enabled) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_lpd_enabled) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_peer_limit_global) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_peer_limit_per_torrent) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_peer_port) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_peer_port_random_on_start) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_pex_enabled) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_port_forwarding_enabled) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_queue_stalled_enabled) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_queue_stalled_minutes) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_rename_partial_files) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_rpc_version) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_rpc_version_minimum) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_script_torrent_done_enabled) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_script_torrent_done_filename) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_seed_queue_enabled) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_seed_queue_size) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_seedRatioLimit) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_seedRatioLimited) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_speed_limit_down) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_speed_limit_down_enabled) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_speed_limit_up) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_speed_limit_up_enabled) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_start_added_torrents) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_trash_original_torrent_files) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_units) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_utp_enabled) != NULL);
-    check(tr_variantDictFind(args, TR_KEY_version) != NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_alt_speed_down), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_alt_speed_enabled), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_alt_speed_time_begin), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_alt_speed_time_day), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_alt_speed_time_enabled), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_alt_speed_time_end), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_alt_speed_up), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_blocklist_enabled), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_blocklist_size), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_blocklist_url), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_cache_size_mb), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_config_dir), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_dht_enabled), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_download_dir), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_download_dir_free_space), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_download_queue_enabled), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_download_queue_size), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_encryption), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_idle_seeding_limit), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_idle_seeding_limit_enabled), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_incomplete_dir), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_incomplete_dir_enabled), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_lpd_enabled), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_peer_limit_global), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_peer_limit_per_torrent), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_peer_port), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_peer_port_random_on_start), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_pex_enabled), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_port_forwarding_enabled), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_queue_stalled_enabled), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_queue_stalled_minutes), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_rename_partial_files), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_rpc_version), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_rpc_version_minimum), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_script_torrent_done_enabled), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_script_torrent_done_filename), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_seed_queue_enabled), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_seed_queue_size), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_seedRatioLimit), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_seedRatioLimited), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_speed_limit_down), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_speed_limit_down_enabled), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_speed_limit_up), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_speed_limit_up_enabled), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_start_added_torrents), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_trash_original_torrent_files), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_units), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_utp_enabled), !=, NULL);
+    check_ptr(tr_variantDictFind(args, TR_KEY_version), !=, NULL);
     tr_variantFree(&response);
 
     /* cleanup */
index 7f3f454f9c086cb4d5a9bac4d980ae8c03d6efe5..aef1a82443b7cf3926bd48eec863f9c01170f44a 100644 (file)
@@ -28,8 +28,8 @@ static int testPeerId(void)
 
         tr_peerIdInit(peer_id);
 
-        check(strlen((char*)peer_id) == PEER_ID_LEN);
-        check(memcmp(peer_id, PEERID_PREFIX, 8) == 0);
+        check_uint(strlen((char*)peer_id), ==, PEER_ID_LEN);
+        check_mem(peer_id, ==, PEERID_PREFIX, 8);
 
         for (int j = 8; j < PEER_ID_LEN; ++j)
         {
@@ -37,7 +37,7 @@ static int testPeerId(void)
             val += strtoul(tmp, NULL, 36);
         }
 
-        check(val % 36 == 0);
+        check_int(val % 36, ==, 0);
     }
 
     return 0;
@@ -55,13 +55,13 @@ static int test_session_id(void)
     check(!tr_session_id_is_local("test"));
 
     session_id = tr_session_id_new();
-    check(session_id != NULL);
+    check_ptr(session_id, !=, NULL);
 
     tr_timeUpdate(0);
 
     session_id_str_1 = tr_session_id_get_current(session_id);
-    check(session_id_str_1 != NULL);
-    check(strlen(session_id_str_1) == 48);
+    check_str(session_id_str_1, !=, NULL);
+    check_uint(strlen(session_id_str_1), ==, 48);
     session_id_str_1 = tr_strdup(session_id_str_1);
 
     check(tr_session_id_is_local(session_id_str_1));
@@ -71,18 +71,18 @@ static int test_session_id(void)
     check(tr_session_id_is_local(session_id_str_1));
 
     session_id_str_2 = tr_session_id_get_current(session_id);
-    check(session_id_str_2 != NULL);
-    check(strlen(session_id_str_2) == 48);
-    check(strcmp(session_id_str_2, session_id_str_1) == 0);
+    check_str(session_id_str_2, !=, NULL);
+    check_uint(strlen(session_id_str_2), ==, 48);
+    check_str(session_id_str_2, ==, session_id_str_1);
 
     tr_timeUpdate(60 * 60);
 
     check(tr_session_id_is_local(session_id_str_1));
 
     session_id_str_2 = tr_session_id_get_current(session_id);
-    check(session_id_str_2 != NULL);
-    check(strlen(session_id_str_2) == 48);
-    check(strcmp(session_id_str_2, session_id_str_1) != 0);
+    check_str(session_id_str_2, !=, NULL);
+    check_uint(strlen(session_id_str_2), ==, 48);
+    check_str(session_id_str_2, !=, session_id_str_1);
     session_id_str_2 = tr_strdup(session_id_str_2);
 
     check(tr_session_id_is_local(session_id_str_2));
@@ -94,10 +94,10 @@ static int test_session_id(void)
     check(tr_session_id_is_local(session_id_str_1));
 
     session_id_str_3 = tr_session_id_get_current(session_id);
-    check(session_id_str_3 != NULL);
-    check(strlen(session_id_str_3) == 48);
-    check(strcmp(session_id_str_3, session_id_str_2) != 0);
-    check(strcmp(session_id_str_3, session_id_str_1) != 0);
+    check_str(session_id_str_3, !=, NULL);
+    check_uint(strlen(session_id_str_3), ==, 48);
+    check_str(session_id_str_3, !=, session_id_str_2);
+    check_str(session_id_str_3, !=, session_id_str_1);
     session_id_str_3 = tr_strdup(session_id_str_3);
 
     check(tr_session_id_is_local(session_id_str_3));
@@ -120,9 +120,9 @@ static int test_session_id(void)
     check(!tr_session_id_is_local(session_id_str_2));
     check(!tr_session_id_is_local(session_id_str_1));
 
-    tr_free(session_id_str_3);
-    tr_free(session_id_str_2);
-    tr_free(session_id_str_1);
+    tr_free((char*)session_id_str_3);
+    tr_free((char*)session_id_str_2);
+    tr_free((char*)session_id_str_1);
 
     return 0;
 }
index 877614b7d5be9e0bb5e0b6269106d3a1f8db535e..aec6791adac77907578b14afdc7970e448addd5f 100644 (file)
@@ -34,7 +34,7 @@ static int run_test(int argc, char const** argv, int expected_n, int* expected_c
 
     while ((c = tr_getopt("summary", argc, argv, options, &optarg)) != TR_OPT_DONE)
     {
-        check(n < expected_n);
+        check_int(n, <, expected_n);
         check_int(c, ==, expected_c[n]);
         check_str(optarg, ==, expected_optarg[n]);
         ++n;
index 24c46570f5351a94a6bb9af2f88ff21b4701b2ed..1a22cab4cec2586901e7c554881f10c5f772c925 100644 (file)
@@ -59,21 +59,21 @@ static int test_strstrip(void)
     /* strstrip */
     in = tr_strdup("   test    ");
     out = tr_strstrip(in);
-    check(in == out);
+    check_ptr(in, ==, out);
     check_str(out, ==, "test");
     tr_free(in);
 
     /* strstrip */
     in = tr_strdup(" test test ");
     out = tr_strstrip(in);
-    check(in == out);
+    check_ptr(in, ==, out);
     check_str(out, ==, "test test");
     tr_free(in);
 
     /* strstrip */
     in = tr_strdup("test");
     out = tr_strstrip(in);
-    check(in == out);
+    check_ptr(in, ==, out);
     check_str(out, ==, "test");
     tr_free(in);
 
@@ -113,7 +113,7 @@ static int test_utf8(void)
     /* this version is not utf-8 (but cp866) */
     in = "\x92\xE0\xE3\xA4\xAD\xAE \xA1\xEB\xE2\xEC \x81\xAE\xA3\xAE\xAC";
     out = tr_utf8clean(in, 17);
-    check(out != NULL);
+    check_ptr(out, !=, NULL);
     check(strlen(out) == 17 || strlen(out) == 33);
     check(tr_utf8_validate(out, TR_BAD_SIZE, NULL));
     tr_free(out);
@@ -121,21 +121,21 @@ static int test_utf8(void)
     /* same string, but utf-8 clean */
     in = "Трудно быть Богом";
     out = tr_utf8clean(in, TR_BAD_SIZE);
-    check(out != NULL);
+    check_ptr(out, !=, NULL);
     check(tr_utf8_validate(out, TR_BAD_SIZE, NULL));
     check_str(out, ==, in);
     tr_free(out);
 
     in = "\xF4\x00\x81\x82";
     out = tr_utf8clean(in, 4);
-    check(out != NULL);
+    check_ptr(out, !=, NULL);
     check(strlen(out) == 1 || strlen(out) == 2);
     check(tr_utf8_validate(out, TR_BAD_SIZE, NULL));
     tr_free(out);
 
     in = "\xF4\x33\x81\x82";
     out = tr_utf8clean(in, 4);
-    check(out != NULL);
+    check_ptr(out, !=, NULL);
     check(strlen(out) == 4 || strlen(out) == 7);
     check(tr_utf8_validate(out, TR_BAD_SIZE, NULL));
     tr_free(out);
@@ -159,8 +159,8 @@ static int test_numbers(void)
     tr_free(numbers);
 
     numbers = tr_parseNumberRange("1-5,3-7,2-6", TR_BAD_SIZE, &count);
-    check(count == 7);
-    check(numbers != NULL);
+    check_int(count, ==, 7);
+    check_ptr(numbers, !=, NULL);
 
     for (int i = 0; i < count; ++i)
     {
@@ -171,15 +171,15 @@ static int test_numbers(void)
 
     numbers = tr_parseNumberRange("1-Hello", TR_BAD_SIZE, &count);
     check_int(count, ==, 0);
-    check(numbers == NULL);
+    check_ptr(numbers, ==, NULL);
 
     numbers = tr_parseNumberRange("1-", TR_BAD_SIZE, &count);
     check_int(count, ==, 0);
-    check(numbers == NULL);
+    check_ptr(numbers, ==, NULL);
 
     numbers = tr_parseNumberRange("Hello", TR_BAD_SIZE, &count);
     check_int(count, ==, 0);
-    check(numbers == NULL);
+    check_ptr(numbers, ==, NULL);
 
     return 0;
 }
@@ -262,7 +262,7 @@ static int test_quickFindFirst_Iteration(size_t const k, size_t const n, int* bu
         }
     }
 
-    check(highest_low <= lowest_high);
+    check_int(highest_low, <=, lowest_high);
 
     return 0;
 }
@@ -288,9 +288,9 @@ static int test_memmem(void)
     char const haystack[12] = "abcabcabcabc";
     char const needle[3] = "cab";
 
-    check(tr_memmem(haystack, sizeof(haystack), haystack, sizeof(haystack)) == haystack);
-    check(tr_memmem(haystack, sizeof(haystack), needle, sizeof(needle)) == haystack + 2);
-    check(tr_memmem(needle, sizeof(needle), haystack, sizeof(haystack)) == NULL);
+    check_ptr(tr_memmem(haystack, sizeof(haystack), haystack, sizeof(haystack)), ==, haystack);
+    check_ptr(tr_memmem(haystack, sizeof(haystack), needle, sizeof(needle)), ==, haystack + 2);
+    check_ptr(tr_memmem(needle, sizeof(needle), haystack, sizeof(haystack)), ==, NULL);
 
     return 0;
 }
@@ -492,7 +492,7 @@ static int test_env(void)
     x = tr_env_get_int(test_key, 123);
     check_int(x, ==, 123);
     s = tr_env_get_string(test_key, NULL);
-    check(s == NULL);
+    check_str(s, ==, NULL);
     s = tr_env_get_string(test_key, "a");
     check_str(s, ==, "a");
     tr_free(s);
index 3e675823c8c84b8a93859430a97b405d6bccc606..c42606241394d03da835f8f56cb825882e27f373 100644 (file)
@@ -38,7 +38,7 @@ static int testInt(void)
     err = tr_bencParseInt(buf, buf + 4, &end, &val);
     check_int(err, ==, 0);
     check_int(val, ==, 64);
-    check(buf + 4 == end);
+    check_ptr(end, ==, buf + 4);
 
     /* missing 'e' */
     end = NULL;
@@ -46,34 +46,34 @@ static int testInt(void)
     err = tr_bencParseInt(buf, buf + 3, &end, &val);
     check_int(err, ==, EILSEQ);
     check_int(val, ==, 888);
-    check(end == NULL);
+    check_ptr(end, ==, NULL);
 
     /* empty buffer */
     err = tr_bencParseInt(buf, buf + 0, &end, &val);
     check_int(err, ==, EILSEQ);
     check_int(val, ==, 888);
-    check(end == NULL);
+    check_ptr(end, ==, NULL);
 
     /* bad number */
     tr_snprintf((char*)buf, sizeof(buf), "i6z4e");
     err = tr_bencParseInt(buf, buf + 5, &end, &val);
     check_int(err, ==, EILSEQ);
     check_int(val, ==, 888);
-    check(end == NULL);
+    check_ptr(end, ==, NULL);
 
     /* negative number */
     tr_snprintf((char*)buf, sizeof(buf), "i-3e");
     err = tr_bencParseInt(buf, buf + 4, &end, &val);
     check_int(err, ==, 0);
     check_int(val, ==, -3);
-    check(buf + 4 == end);
+    check_ptr(end, ==, buf + 4);
 
     /* zero */
     tr_snprintf((char*)buf, sizeof(buf), "i0e");
     err = tr_bencParseInt(buf, buf + 4, &end, &val);
     check_int(err, ==, 0);
     check_int(val, ==, 0);
-    check(buf + 3 == end);
+    check_ptr(end, ==, buf + 3);
 
     /* no leading zeroes allowed */
     val = 0;
@@ -82,7 +82,7 @@ static int testInt(void)
     err = tr_bencParseInt(buf, buf + 4, &end, &val);
     check_int(err, ==, EILSEQ);
     check_int(val, ==, 0);
-    check(NULL == end);
+    check_ptr(end, ==, NULL);
 
     return 0;
 }
@@ -101,17 +101,16 @@ static int testStr(void)
     err = tr_bencParseStr(buf, buf + n, &end, &str, &len);
     check_int(err, ==, EILSEQ);
     check_uint(len, ==, 0);
-    check(str == NULL);
-    check(end == NULL);
-    check(len == 0);
+    check_ptr(str, ==, NULL);
+    check_ptr(end, ==, NULL);
 
     /* good string */
     n = tr_snprintf((char*)buf, sizeof(buf), "4:boat");
     err = tr_bencParseStr(buf, buf + n, &end, &str, &len);
     check_int(err, ==, 0);
     check_uint(len, ==, 4);
-    check(strncmp((char const*)str, "boat", len) == 0);
-    check(end == buf + 6);
+    check_mem(str, ==, "boat", len);
+    check_ptr(end, ==, buf + 6);
     str = NULL;
     end = NULL;
     len = 0;
@@ -120,17 +119,16 @@ static int testStr(void)
     err = tr_bencParseStr(buf, buf + (n - 1), &end, &str, &len);
     check_int(err, ==, EILSEQ);
     check_uint(len, ==, 0);
-    check(str == NULL);
-    check(end == NULL);
-    check(len == 0);
+    check_ptr(str, ==, NULL);
+    check_ptr(end, ==, NULL);
 
     /* empty string */
     n = tr_snprintf((char*)buf, sizeof(buf), "0:");
     err = tr_bencParseStr(buf, buf + n, &end, &str, &len);
     check_int(err, ==, 0);
     check_uint(len, ==, 0);
-    check(*str == '\0');
-    check(end == buf + 2);
+    check_uint(*str, ==, '\0');
+    check_ptr(end, ==, buf + 2);
     str = NULL;
     end = NULL;
     len = 0;
@@ -140,8 +138,8 @@ static int testStr(void)
     err = tr_bencParseStr(buf, buf + n, &end, &str, &len);
     check_int(err, ==, 0);
     check_uint(len, ==, 3);
-    check(strncmp((char const*)str, "boa", len) == 0);
-    check(end == buf + 5);
+    check_mem(str, ==, "boa", len);
+    check_ptr(end, ==, buf + 5);
     str = NULL;
     end = NULL;
     len = 0;
@@ -162,16 +160,16 @@ static int testString(char const* str, bool isGood)
 
     if (!isGood)
     {
-        check(err != 0);
+        check_int(err, !=, 0);
     }
     else
     {
-        check(err == 0);
+        check_int(err, ==, 0);
 #if 0
         fprintf(stderr, "in: [%s]\n", str);
         fprintf(stderr, "out:\n%s", tr_variantToStr(&val, TR_VARIANT_FMT_JSON, NULL));
 #endif
-        check(end == str + len);
+        check_ptr(end, ==, str + len);
         saved = tr_variantToStr(&val, TR_VARIANT_FMT_BENC, &savedLen);
         check_str(saved, ==, str);
         check_uint(savedLen, ==, len);
@@ -196,17 +194,17 @@ static int testParse(void)
 
     tr_snprintf((char*)buf, sizeof(buf), "i64e");
     err = tr_variantFromBencFull(&val, buf, sizeof(buf), NULL, &end);
-    check(err == 0);
+    check_int(err, ==, 0);
     check(tr_variantGetInt(&val, &i));
     check_int(i, ==, 64);
-    check(end == buf + 4);
+    check_ptr(end, ==, buf + 4);
     tr_variantFree(&val);
 
     tr_snprintf((char*)buf, sizeof(buf), "li64ei32ei16ee");
     err = tr_variantFromBencFull(&val, buf, sizeof(buf), NULL, &end);
-    check(err == 0);
-    check(end == buf + strlen((char*)buf));
-    check(val.val.l.count == 3);
+    check_int(err, ==, 0);
+    check_ptr(end, ==, buf + strlen((char*)buf));
+    check_uint(val.val.l.count, ==, 3);
     check(tr_variantGetInt(&val.val.l.vals[0], &i));
     check_int(i, ==, 64);
     check(tr_variantGetInt(&val.val.l.vals[1], &i));
@@ -221,14 +219,14 @@ static int testParse(void)
     end = NULL;
     tr_snprintf((char*)buf, sizeof(buf), "lllee");
     err = tr_variantFromBencFull(&val, buf, sizeof(buf), NULL, &end);
-    check(err != 0);
-    check(end == NULL);
+    check_int(err, !=, 0);
+    check_ptr(end, ==, NULL);
 
     end = NULL;
     tr_snprintf((char*)buf, sizeof(buf), "le");
     err = tr_variantFromBencFull(&val, buf, sizeof(buf), NULL, &end);
-    check(err == 0);
-    check(end == buf + 2);
+    check_int(err, ==, 0);
+    check_ptr(end, ==, buf + 2);
     saved = tr_variantToStr(&val, TR_VARIANT_FMT_BENC, &len);
     check_str(saved, ==, "le");
     tr_free(saved);
@@ -285,10 +283,10 @@ static int testParse(void)
     end = NULL;
     tr_snprintf((char*)buf, sizeof(buf), "lld1:bi32e1:ai64eeee");
     err = tr_variantFromBencFull(&val, buf, sizeof(buf), NULL, &end);
-    check(err == 0);
-    check(end == buf + strlen((char const*)buf));
-    check((child = tr_variantListChild(&val, 0)) != NULL);
-    check((child2 = tr_variantListChild(child, 0)) != NULL);
+    check_int(err, ==, 0);
+    check_ptr(end, ==, buf + strlen((char const*)buf));
+    check_ptr((child = tr_variantListChild(&val, 0)), !=, NULL);
+    check_ptr((child2 = tr_variantListChild(child, 0)), !=, NULL);
     saved = tr_variantToStr(&val, TR_VARIANT_FMT_BENC, &len);
     check_str(saved, ==, "lld1:ai64e1:bi32eeee");
     tr_free(saved);
@@ -298,8 +296,8 @@ static int testParse(void)
     end = NULL;
     tr_snprintf((char*)buf, sizeof(buf), "leee");
     err = tr_variantFromBencFull(&val, buf, sizeof(buf), NULL, &end);
-    check(err == 0);
-    check(end == buf + 2);
+    check_int(err, ==, 0);
+    check_ptr(end, ==, buf + 2);
     saved = tr_variantToStr(&val, TR_VARIANT_FMT_BENC, &len);
     check_str(saved, ==, "le");
     tr_free(saved);
@@ -309,13 +307,13 @@ static int testParse(void)
     end = NULL;
     tr_snprintf((char*)buf, sizeof(buf), "l1:a1:b1:c");
     err = tr_variantFromBencFull(&val, buf, strlen(buf), NULL, &end);
-    check(err != 0);
+    check_int(err, !=, 0);
 
     /* incomplete string */
     end = NULL;
     tr_snprintf((char*)buf, sizeof(buf), "1:");
     err = tr_variantFromBencFull(&val, buf, strlen(buf), NULL, &end);
-    check(err != 0);
+    check_int(err, !=, 0);
 
     return 0;
 }
@@ -488,7 +486,7 @@ static int testStackSmash(void)
     in[depth * 2] = '\0';
     err = tr_variantFromBencFull(&val, in, depth * 2, NULL, &end);
     check_int(err, ==, 0);
-    check(end == in + depth * 2);
+    check_ptr(end, ==, in + depth * 2);
     saved = tr_variantToStr(&val, TR_VARIANT_FMT_BENC, &len);
     check_str(saved, ==, in);
     tr_free(in);
@@ -523,13 +521,13 @@ static int testBool(void)
     check(tr_variantDictFindBool(&top, key4, &boolVal));
     check(boolVal);
     check(tr_variantDictFindInt(&top, key1, &intVal));
-    check(intVal == 0);
+    check_int(intVal, ==, 0);
     check(tr_variantDictFindInt(&top, key2, &intVal));
-    check(intVal == 0);
+    check_int(intVal, ==, 0);
     check(tr_variantDictFindInt(&top, key3, &intVal));
-    check(intVal != 0);
+    check_int(intVal, !=, 0);
     check(tr_variantDictFindInt(&top, key4, &intVal));
-    check(intVal != 0);
+    check_int(intVal, !=, 0);
 
     tr_variantFree(&top);
     return 0;
@@ -561,13 +559,13 @@ static int testParse2(void)
     benc = tr_variantToStr(&top, TR_VARIANT_FMT_BENC, &len);
     check_str(benc, ==, "d14:this-is-a-booli1e14:this-is-a-real8:0.50000016:this-is-a-string16:this-is-a-string14:this-is-an-"
         "inti1234ee");
-    check(tr_variantFromBencFull(&top2, benc, len, NULL, &end) == 0);
-    check(end == benc + len);
+    check_int(tr_variantFromBencFull(&top2, benc, len, NULL, &end), ==, 0);
+    check_ptr(end, ==, benc + len);
     check(tr_variantIsDict(&top2));
     check(tr_variantDictFindInt(&top, key_int, &intVal));
     check_int(intVal, ==, 1234);
     check(tr_variantDictFindBool(&top, key_bool, &boolVal));
-    check(boolVal == true);
+    check(boolVal);
     check(tr_variantDictFindStr(&top, key_str, &strVal, &strLen));
     check_uint(strLen, ==, 16);
     check_str(strVal, ==, "this-is-a-string");
index 13274b6918ab2a07d9722604ffdd3f23d2ad3df6..a9fe5f8ae7de7058ebcbe82c6b58cda0f24501fb 100644 (file)
@@ -113,7 +113,7 @@ static int test_construct(void)
     ev_base = event_base_new();
 
     wd = create_watchdir(test_dir, &callback, NULL, ev_base);
-    check(wd != NULL);
+    check_ptr(wd, !=, NULL);
     check(tr_sys_path_is_same(test_dir, tr_watchdir_get_path(wd), NULL));
 
     process_events();
@@ -141,7 +141,7 @@ static int test_initial_scan(void)
         reset_callback_data(&wd_data, TR_WATCHDIR_ACCEPT);
 
         tr_watchdir_t wd = create_watchdir(test_dir, &callback, &wd_data, ev_base);
-        check(wd != NULL);
+        check_ptr(wd, !=, NULL);
 
         process_events();
         check_ptr(wd_data.dir, ==, NULL);
@@ -158,7 +158,7 @@ static int test_initial_scan(void)
         reset_callback_data(&wd_data, TR_WATCHDIR_ACCEPT);
 
         tr_watchdir_t wd = create_watchdir(test_dir, &callback, &wd_data, ev_base);
-        check(wd != NULL);
+        check_ptr(wd, !=, NULL);
 
         process_events();
         check_ptr(wd_data.dir, ==, wd);
@@ -188,7 +188,7 @@ static int test_watch(void)
 
     reset_callback_data(&wd_data, TR_WATCHDIR_ACCEPT);
     wd = create_watchdir(test_dir, &callback, &wd_data, ev_base);
-    check(wd != NULL);
+    check_ptr(wd, !=, NULL);
 
     process_events();
     check_ptr(wd_data.dir, ==, NULL);
@@ -244,11 +244,11 @@ static int test_watch_two_dirs(void)
 
     reset_callback_data(&wd1_data, TR_WATCHDIR_ACCEPT);
     wd1 = create_watchdir(dir1, &callback, &wd1_data, ev_base);
-    check(wd1 != NULL);
+    check_ptr(wd1, !=, NULL);
 
     reset_callback_data(&wd2_data, TR_WATCHDIR_ACCEPT);
     wd2 = create_watchdir(dir2, &callback, &wd2_data, ev_base);
-    check(wd2 != NULL);
+    check_ptr(wd2, !=, NULL);
 
     process_events();
     check_ptr(wd1_data.dir, ==, NULL);
@@ -351,7 +351,7 @@ static int test_retry(void)
 
     reset_callback_data(&wd_data, TR_WATCHDIR_RETRY);
     wd = create_watchdir(test_dir, &callback, &wd_data, ev_base);
-    check(wd != NULL);
+    check_ptr(wd, !=, NULL);
 
     process_events();
     check_ptr(wd_data.dir, ==, NULL);