/* init the session */
session = libttest_session_init(NULL);
check(!tr_blocklistExists(session));
- check_int_eq(0, tr_blocklistGetRuleCount(session));
+ check_int(tr_blocklistGetRuleCount(session), ==, 0);
/* init the blocklist */
path = tr_buildPath(tr_sessionGetConfigDir(session), "blocklists", "level1", NULL);
tr_free(path);
tr_sessionReloadBlocklists(session);
check(tr_blocklistExists(session));
- check_int_eq(4, tr_blocklistGetRuleCount(session));
+ check_int(tr_blocklistGetRuleCount(session), ==, 4);
/* enable the blocklist */
check(!tr_blocklistIsEnabled(session));
path = tr_buildPath(tr_sessionGetConfigDir(session), "blocklists", "level1", NULL);
/* no blocklist to start with... */
- check_int_eq(0, tr_blocklistGetRuleCount(session));
+ check_int(tr_blocklistGetRuleCount(session), ==, 0);
/* test that updated source files will get loaded */
create_text_file(path, contents1);
tr_sessionReloadBlocklists(session);
- check_int_eq(4, tr_blocklistGetRuleCount(session));
+ check_int(tr_blocklistGetRuleCount(session), ==, 4);
/* test that updated source files will get loaded */
create_text_file(path, contents2);
tr_sessionReloadBlocklists(session);
- check_int_eq(5, tr_blocklistGetRuleCount(session));
+ check_int(tr_blocklistGetRuleCount(session), ==, 5);
/* test that updated source files will get loaded */
create_text_file(path, contents1);
tr_sessionReloadBlocklists(session);
- check_int_eq(4, tr_blocklistGetRuleCount(session));
+ check_int(tr_blocklistGetRuleCount(session), ==, 4);
/* ensure that new files, if bad, get skipped */
create_text_file(path, "# nothing useful\n");
tr_sessionReloadBlocklists(session);
- check_int_eq(4, tr_blocklistGetRuleCount(session));
+ check_int(tr_blocklistGetRuleCount(session), ==, 4);
/* cleanup */
libttest_session_close(session);
tr_error_set(&err, 1, "error: %s (%d)", "oops", 2);
check(err != NULL);
- check_int_eq(1, err->code);
+ check_int(err->code, ==, 1);
check_str(err->message, ==, "error: oops (2)");
tr_error_clear(&err);
check(err == NULL);
tr_error_set_literal(&err, 2, "oops");
check(err != NULL);
- check_int_eq(2, err->code);
+ check_int(err->code, ==, 2);
check_str(err->message, ==, "oops");
tr_error_prefix(&err, "error: ");
check(err != NULL);
- check_int_eq(2, err->code);
+ check_int(err->code, ==, 2);
check_str(err->message, ==, "error: oops");
tr_error_free(err);
tr_error_set_literal(&err, 1, "oops");
check(err != NULL);
- check_int_eq(1, err->code);
+ check_int(err->code, ==, 1);
check_str(err->message, ==, "oops");
tr_error_propagate(&err2, &err);
check(err2 != NULL);
- check_int_eq(1, err2->code);
+ check_int(err2->code, ==, 1);
check_str(err2->message, ==, "oops");
check(err == NULL);
tr_error_propagate_prefixed(&err, &err2, "error: ");
check(err != NULL);
- check_int_eq(1, err->code);
+ check_int(err->code, ==, 1);
check_str(err->message, ==, "error: oops");
check(err2 == NULL);
clear_path_info(&info);
check(tr_sys_path_get_info(path1, 0, &info, &err));
check(err == NULL);
- check_int_eq(TR_SYS_PATH_IS_FILE, info.type);
+ check_int(info.type, ==, TR_SYS_PATH_IS_FILE);
check_uint_eq(4, info.size);
check(info.last_modified_at >= t && info.last_modified_at <= time(NULL));
clear_path_info(&info);
check(tr_sys_file_get_info(fd, &info, &err));
check(err == NULL);
- check_int_eq(TR_SYS_PATH_IS_FILE, info.type);
+ check_int(info.type, ==, TR_SYS_PATH_IS_FILE);
check_uint_eq(4, info.size);
check(info.last_modified_at >= t && info.last_modified_at <= time(NULL));
tr_sys_file_close(fd, NULL);
clear_path_info(&info);
check(tr_sys_path_get_info(path1, 0, &info, &err));
check(err == NULL);
- check_int_eq(TR_SYS_PATH_IS_DIRECTORY, info.type);
+ 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));
tr_sys_path_remove(path1, NULL);
clear_path_info(&info);
check(tr_sys_path_get_info(path1, 0, &info, &err));
check(err == NULL);
- check_int_eq(TR_SYS_PATH_IS_FILE, info.type);
+ check_int(info.type, ==, TR_SYS_PATH_IS_FILE);
check_uint_eq(4, info.size);
check(info.last_modified_at >= t && info.last_modified_at <= time(NULL));
clear_path_info(&info);
check(tr_sys_file_get_info(fd, &info, &err));
check(err == NULL);
- check_int_eq(TR_SYS_PATH_IS_FILE, info.type);
+ check_int(info.type, ==, TR_SYS_PATH_IS_FILE);
check_uint_eq(4, info.size);
check(info.last_modified_at >= t && info.last_modified_at <= time(NULL));
tr_sys_file_close(fd, NULL);
clear_path_info(&info);
check(tr_sys_path_get_info(path1, 0, &info, &err));
check(err == NULL);
- check_int_eq(TR_SYS_PATH_IS_DIRECTORY, info.type);
+ 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(err == NULL);
check_uint_eq(4, n);
- check_int_eq(0, memcmp(buf, "test", 4));
+ check_int(memcmp(buf, "test", 4), ==, 0);
check(tr_sys_file_seek(fd, -3, TR_SEEK_CUR, &n, &err));
check(err == NULL);
check(err == NULL);
check_uint_eq(4, n);
- check_int_eq(0, memcmp(buf, "tEst", 4));
+ check_int(memcmp(buf, "tEst", 4), ==, 0);
check(tr_sys_file_seek(fd, 0, TR_SEEK_END, &n, &err));
check(err == NULL);
check(err == NULL);
check_uint_eq(7, n);
- check_int_eq(0, memcmp(buf, "tEst ok", 7));
+ check_int(memcmp(buf, "tEst ok", 7), ==, 0);
check(tr_sys_file_write_at(fd, "-", 1, 4, &n, &err));
check(err == NULL);
check(err == NULL);
check_uint_eq(5, n);
- check_int_eq(0, memcmp(buf, "st-ok", 5));
+ check_int(memcmp(buf, "st-ok", 5), ==, 0);
tr_sys_file_close(fd, NULL);
check(view != NULL);
check(err == NULL);
- check_int_eq(0, memcmp(view, "test", 4));
+ check_int(memcmp(view, "test", 4), ==, 0);
#ifdef HAVE_UNIFIED_BUFFER_CACHE
tr_sys_file_write_at(fd, "E", 1, 1, NULL, NULL);
- check_int_eq(0, memcmp(view, "tEst", 4));
+ check_int(memcmp(view, "tEst", 4), ==, 0);
#endif
memset(&h, 0, sizeof(tr_recentHistory));
tr_historyAdd(&h, 10000, 1);
- check_int_eq(0, (int)tr_historyGet(&h, 12000, 1000));
- check_int_eq(1, (int)tr_historyGet(&h, 12000, 3000));
- check_int_eq(1, (int)tr_historyGet(&h, 12000, 5000));
+ check_int((int)tr_historyGet(&h, 12000, 1000), ==, 0);
+ check_int((int)tr_historyGet(&h, 12000, 3000), ==, 1);
+ check_int((int)tr_historyGet(&h, 12000, 5000), ==, 1);
tr_historyAdd(&h, 20000, 1);
- check_int_eq(0, (int)tr_historyGet(&h, 22000, 1000));
- check_int_eq(1, (int)tr_historyGet(&h, 22000, 3000));
- check_int_eq(2, (int)tr_historyGet(&h, 22000, 15000));
- check_int_eq(2, (int)tr_historyGet(&h, 22000, 20000));
+ check_int((int)tr_historyGet(&h, 22000, 1000), ==, 0);
+ check_int((int)tr_historyGet(&h, 22000, 3000), ==, 1);
+ check_int((int)tr_historyGet(&h, 22000, 15000), ==, 2);
+ check_int((int)tr_historyGet(&h, 22000, 20000), ==, 2);
return 0;
}
" \"null\": null }";
err = tr_variantFromJson(&top, in, strlen(in));
- check_int_eq(0, err);
+ check_int(err, ==, 0);
check(tr_variantIsDict(&top));
str = NULL;
key = tr_quark_new("string", 6);
check_str(str, ==, "bell \b formfeed \f linefeed \n carriage return \r tab \t");
i = 0;
check(tr_variantDictFindInt(&top, tr_quark_new("int", 3), &i));
- check_int_eq(5, i);
+ check_int(i, ==, 5);
d = 0;
check(tr_variantDictFindReal(&top, tr_quark_new("float", 5), &d));
- check_int_eq(65, ((int)(d * 10)));
+ check_int(((int)(d * 10)), ==, 65);
f = false;
check(tr_variantDictFindBool(&top, tr_quark_new("true", 4), &f));
- check_int_eq(true, f);
+ check_int(f, ==, true);
check(tr_variantDictFindBool(&top, tr_quark_new("false", 5), &f));
- check_int_eq(false, f);
+ check_int(f, ==, false);
check(tr_variantDictFindStr(&top, tr_quark_new("null", 4), &str, NULL));
check_str(str, ==, "");
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_eq(666, i);
+ check_int(i, ==, 666);
check((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(tr_variantIsList(ids));
check_uint_eq(2, tr_variantListSize(ids));
check(tr_variantGetInt(tr_variantListChild(ids, 0), &i));
- check_int_eq(7, i);
+ check_int(i, ==, 7);
check(tr_variantGetInt(tr_variantListChild(ids, 1), &i));
- check_int_eq(10, i);
+ check_int(i, ==, 10);
tr_variantFree(&top);
return 0;
char const* str;
int const err = tr_variantFromJson(&top, in, strlen(in));
- check_int_eq(0, err);
+ check_int(err, ==, 0);
check(tr_variantDictFindStr(&top, tr_quark_new("string-1", 8), &str, NULL));
check_str(str, ==, "/usr/lib");
return pass;
}
-bool check_int_eq_impl(char const* file, int line, intmax_t expected, intmax_t actual)
+bool libtest_check_int(char const* file, int line, bool pass, intmax_t lhs, intmax_t rhs, char const* lhs_str,
+ char const* op_str, char const* rhs_str)
{
- bool const pass = expected == actual;
-
if (should_print(pass))
{
- if (pass)
- {
- fprintf(stderr, "PASS %s:%d\n", file, line);
- }
- else
- {
- fprintf(stderr, "FAIL %s:%d, expected \"%jd\", got \"%jd\"\n", file, line, expected, actual);
- }
+ fprintf(stderr, "%s %s:%d: %s %s %s (%jd %s %jd)\n", pass ? "PASS" : "FAIL", file, line, lhs_str, op_str, rhs_str, lhs,
+ op_str, rhs);
}
return pass;
bool should_print(bool pass);
bool check_condition_impl(char const* file, int line, bool condition);
-bool check_int_eq_impl(char const* file, int line, intmax_t expected, intmax_t actual);
bool check_uint_eq_impl(char const* file, int line, uintmax_t expected, uintmax_t actual);
bool check_ptr_eq_impl(char const* file, int line, void const* expected, void const* actual);
bool libtest_check_str(char const* file, int line, bool pass, char const* lhs, char const* rhs, char const* lhs_str,
char const* op_str, char const* rhs_str);
+bool libtest_check_int(char const* file, int line, bool pass, intmax_t lhs, intmax_t rhs, char const* lhs_str,
+ char const* op_str, char const* rhs_str);
/***
****
} \
while (0)
-#define check_int_eq(expected, actual) \
+#define check_int(lhs, op, rhs) \
do \
{ \
++current_test; \
\
- if (!check_int_eq_impl(__FILE__, __LINE__, (expected), (actual))) \
+ intmax_t const check_int_lhs = (lhs); \
+ intmax_t const check_int_rhs = (rhs); \
+ \
+ if (!libtest_check_int(__FILE__, __LINE__, check_int_lhs op check_int_rhs, check_int_lhs, check_int_rhs, #lhs, #op, \
+ #rhs)) \
{ \
return current_test; \
} \
"&ws=http%3A%2F%2Fserver.webseed.org%2Fpath%2Fto%2Ffile";
info = tr_magnetParse(uri);
check(info != NULL);
- check_int_eq(2, info->trackerCount);
+ 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_eq(1, info->webseedCount);
+ check_int(info->webseedCount, ==, 1);
check_str(info->webseeds[0], ==, "http://server.webseed.org/path/to/file");
check_str(info->displayName, ==, "Display Name");
"&tr=http%3A%2F%2Ftracker.opentracker.org%2Fannounce";
info = tr_magnetParse(uri);
check(info != NULL);
- check_int_eq(2, info->trackerCount);
+ 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_eq(1, info->webseedCount);
+ check_int(info->webseedCount, ==, 1);
check_str(info->webseeds[0], ==, "http://server.webseed.org/path/to/file");
check_str(info->displayName, ==, "Display Name");
libtest_create_tmpfile_with_contents(input_file, payload, payloadSize);
builder = tr_metaInfoBuilderCreate(input_file);
check_str(builder->top, ==, input_file);
- check_int_eq(1, builder->fileCount);
+ check_int(builder->fileCount, ==, 1);
check_str(builder->files[0].filename, ==, input_file);
- check_int_eq(payloadSize, builder->files[0].size);
- check_int_eq(payloadSize, builder->totalSize);
+ check_int(builder->files[0].size, ==, payloadSize);
+ check_int(builder->totalSize, ==, payloadSize);
check(!builder->isFolder);
check(!builder->abortFlag);
check(isPrivate == builder->isPrivate);
check_str(builder->outputFile, ==, torrent_file);
check_str(builder->comment, ==, comment);
- check_int_eq(trackerCount, builder->trackerCount);
+ check_int(builder->trackerCount, ==, trackerCount);
while (!builder->isDone)
{
libttest_sync();
tr_ctorSetMetainfoFromFile(ctor, torrent_file);
parse_result = tr_torrentParse(ctor, &inf);
- check_int_eq(TR_PARSE_OK, parse_result);
+ check_int(parse_result, ==, TR_PARSE_OK);
/* quick check of some of the parsed metainfo */
- check_int_eq(payloadSize, inf.totalSize);
+ check_int(inf.totalSize, ==, payloadSize);
tmpstr = tr_sys_path_basename(input_file, NULL);
check_str(inf.name, ==, tmpstr);
tr_free(tmpstr);
check_str(inf.comment, ==, comment);
- check_int_eq(1, inf.fileCount);
- check_int_eq(isPrivate, inf.isPrivate);
+ check_int(inf.fileCount, ==, 1);
+ check_int(inf.isPrivate, ==, isPrivate);
check(!inf.isFolder);
- check_int_eq(trackerCount, inf.trackerCount);
+ check_int(inf.trackerCount, ==, trackerCount);
/* cleanup */
tr_free(torrent_file);
builder = tr_metaInfoBuilderCreate(top);
check(!builder->abortFlag);
check_str(builder->top, ==, top);
- check_int_eq(payloadCount, builder->fileCount);
- check_int_eq(totalSize, builder->totalSize);
+ check_int(builder->fileCount, ==, payloadCount);
+ check_int(builder->totalSize, ==, totalSize);
check(builder->isFolder);
for (size_t i = 0; i < builder->fileCount; i++)
{
check_str(builder->files[i].filename, ==, files[i]);
- check_int_eq(payloadSizes[i], builder->files[i].size);
+ check_int(builder->files[i].size, ==, payloadSizes[i]);
}
/* call tr_makeMetaInfo() to build the .torrent file */
check(isPrivate == builder->isPrivate);
check_str(builder->outputFile, ==, torrent_file);
check_str(builder->comment, ==, comment);
- check_int_eq(trackerCount, builder->trackerCount);
+ check_int(builder->trackerCount, ==, trackerCount);
while (!builder->isDone)
{
libttest_sync();
tr_ctorSetMetainfoFromFile(ctor, torrent_file);
parse_result = tr_torrentParse(ctor, &inf);
- check_int_eq(TR_PARSE_OK, parse_result);
+ check_int(parse_result, ==, TR_PARSE_OK);
/* quick check of some of the parsed metainfo */
- check_int_eq(totalSize, inf.totalSize);
+ check_int(inf.totalSize, ==, totalSize);
tmpstr = tr_sys_path_basename(top, NULL);
check_str(inf.name, ==, tmpstr);
tr_free(tmpstr);
check_str(inf.comment, ==, comment);
- check_int_eq(payloadCount, inf.fileCount);
- check_int_eq(isPrivate, inf.isPrivate);
- check_int_eq(builder->isFolder, inf.isFolder);
- check_int_eq(trackerCount, inf.trackerCount);
+ check_int(inf.fileCount, ==, payloadCount);
+ check_int(inf.isPrivate, ==, isPrivate);
+ check_int(inf.isFolder, ==, builder->isFolder);
+ check_int(inf.trackerCount, ==, trackerCount);
/* cleanup */
tr_free(torrent_file);
ctor = tr_ctorNew(NULL);
tr_ctorSetMetainfoFromMagnetLink(ctor, magnet_link);
parse_result = tr_torrentParse(ctor, &inf);
- check_int_eq(inf.fileCount, 0); /* cos it's a magnet link */
- check_int_eq(parse_result, TR_PARSE_OK);
- check_int_eq(inf.trackerCount, 2);
+ check_int(inf.fileCount, ==, 0); /* cos it's a magnet link */
+ check_int(parse_result, ==, TR_PARSE_OK);
+ check_int(inf.trackerCount, ==, 2);
check_str(inf.trackers[0].announce, ==, "http://tracker.publicbt.com/announce");
check_str(inf.trackers[1].announce, ==, "udp://tracker.publicbt.com:80");
- check_int_eq(inf.webseedCount, 1);
+ check_int(inf.webseedCount, ==, 1);
check_str(inf.webseeds[0], ==, "http://transmissionbt.com");
/* cleanup */
{
tr_ctor* ctor = tr_ctorNew(NULL);
int const err = tr_ctorSetMetainfo(ctor, metainfo[i].benc, strlen(metainfo[i].benc));
- check_int_eq(metainfo[i].expected_benc_err, err);
+ check_int(err, ==, metainfo[i].expected_benc_err);
if (err == 0)
{
tr_parse_result const parse_result = tr_torrentParse(ctor, NULL);
- check_int_eq(metainfo[i].expected_parse_result, parse_result);
+ check_int(parse_result, ==, metainfo[i].expected_parse_result);
}
tr_ctorFree(ctor);
tr_wait_msec(50);
}
- check_int_eq(TR_SEED, completeness);
+ check_int(completeness, ==, TR_SEED);
for (tr_file_index_t file_index = 0; file_index < tor->info.fileCount; ++file_index)
{
tr_wait_msec(50);
}
- check_int_eq(TR_LOC_DONE, state);
+ check_int(state, ==, TR_LOC_DONE);
/* confirm the torrent is still complete after being moved */
libttest_blockingTorrentVerify(tor);
str = tr_quark_get_string((tr_quark)i, &len);
check_uint_eq(strlen(str), len);
check(tr_quark_lookup(str, len, &q));
- check_int_eq(i, (int)q);
+ check_int((int)q, ==, i);
}
for (int i = 0; i + 1 < TR_N_KEYS; i++)
}
tr_quark const q = tr_quark_new(NULL, TR_BAD_SIZE);
- check_int_eq(TR_KEY_NONE, (int)q);
+ check_int((int)q, ==, TR_KEY_NONE);
check_str(tr_quark_get_string(q, NULL), ==, "");
return 0;
do \
{ \
tr_stat const* tst = tr_torrentStat(tor); \
- check_int_eq(TR_STATUS_STOPPED, tst->activity); \
- check_int_eq(TR_STAT_OK, tst->error); \
+ check_int(tst->activity, ==, TR_STATUS_STOPPED); \
+ check_int(tst->error, ==, TR_STAT_OK); \
check_uint_eq(totalSize, tst->sizeWhenDone); \
check_uint_eq(totalSize, tst->leftUntilDone); \
check_uint_eq(totalSize, tor->info.totalSize); \
check(tr_isTorrent(tor));
/* sanity check the info */
- check_int_eq(1, tor->info.fileCount);
+ check_int(tor->info.fileCount, ==, 1);
check_str(tor->info.files[0].name, ==, "hello-world.txt");
check(!tor->info.files[0].is_renamed);
/* sanity check the stats again, now that we've added the file */
libttest_blockingTorrentVerify(tor);
st = tr_torrentStat(tor);
- check_int_eq(TR_STATUS_STOPPED, st->activity);
- check_int_eq(TR_STAT_OK, st->error);
+ check_int(st->activity, ==, TR_STATUS_STOPPED);
+ check_int(st->error, ==, TR_STAT_OK);
check_uint_eq(0, st->leftUntilDone);
check_uint_eq(0, st->haveUnchecked);
check_uint_eq(0, st->desiredAvailable);
/* confirm that bad inputs get caught */
- check_int_eq(EINVAL, torrentRenameAndWait(tor, "hello-world.txt", NULL));
- check_int_eq(EINVAL, torrentRenameAndWait(tor, "hello-world.txt", ""));
- check_int_eq(EINVAL, torrentRenameAndWait(tor, "hello-world.txt", "."));
- check_int_eq(EINVAL, torrentRenameAndWait(tor, "hello-world.txt", ".."));
- check_int_eq(0, torrentRenameAndWait(tor, "hello-world.txt", "hello-world.txt"));
- check_int_eq(EINVAL, torrentRenameAndWait(tor, "hello-world.txt", "hello/world.txt"));
+ check_int(torrentRenameAndWait(tor, "hello-world.txt", NULL), ==, EINVAL);
+ check_int(torrentRenameAndWait(tor, "hello-world.txt", ""), ==, EINVAL);
+ check_int(torrentRenameAndWait(tor, "hello-world.txt", "."), ==, EINVAL);
+ check_int(torrentRenameAndWait(tor, "hello-world.txt", ".."), ==, EINVAL);
+ check_int(torrentRenameAndWait(tor, "hello-world.txt", "hello-world.txt"), ==, 0);
+ check_int(torrentRenameAndWait(tor, "hello-world.txt", "hello/world.txt"), ==, EINVAL);
check(!tor->info.files[0].is_renamed);
check_str(tor->info.files[0].name, ==, "hello-world.txt");
tmpstr = tr_buildPath(tor->currentDir, "hello-world.txt", NULL);
check(tr_sys_path_exists(tmpstr, NULL));
check_str(tr_torrentName(tor), ==, "hello-world.txt");
- check_int_eq(0, torrentRenameAndWait(tor, tor->info.name, "foobar"));
+ check_int(torrentRenameAndWait(tor, tor->info.name, "foobar"), ==, 0);
check(!tr_sys_path_exists(tmpstr, NULL)); /* confirm the old filename can't be found */
tr_free(tmpstr);
check(tor->info.files[0].is_renamed); /* confirm the file's 'renamed' flag is set */
tmpstr = tr_buildPath(tor->currentDir, "foobar", NULL);
check(tr_sys_path_exists(tmpstr, NULL));
- check_int_eq(0, torrentRenameAndWait(tor, "foobar", "hello-world.txt"));
+ check_int(torrentRenameAndWait(tor, "foobar", "hello-world.txt"), ==, 0);
check(!tr_sys_path_exists(tmpstr, NULL));
check(tor->info.files[0].is_renamed);
check_str(tor->info.files[0].name, ==, "hello-world.txt");
/* sanity check the (full) stats */
libttest_blockingTorrentVerify(tor);
st = tr_torrentStat(tor);
- check_int_eq(TR_STATUS_STOPPED, st->activity);
- check_int_eq(TR_STAT_OK, st->error);
+ check_int(st->activity, ==, TR_STATUS_STOPPED);
+ check_int(st->error, ==, TR_STAT_OK);
check_uint_eq(0, st->leftUntilDone);
check_uint_eq(0, st->haveUnchecked);
check_uint_eq(0, st->desiredAvailable);
**/
/* rename a leaf... */
- check_int_eq(0, torrentRenameAndWait(tor, "Felidae/Felinae/Felis/catus/Kyphi", "placeholder"));
+ check_int(torrentRenameAndWait(tor, "Felidae/Felinae/Felis/catus/Kyphi", "placeholder"), ==, 0);
check_str(files[1].name, ==, "Felidae/Felinae/Felis/catus/placeholder");
check(testFileExistsAndConsistsOfThisString(tor, 1, "Inquisitive\n"));
/* ...and back again */
- check_int_eq(0, torrentRenameAndWait(tor, "Felidae/Felinae/Felis/catus/placeholder", "Kyphi"));
+ check_int(torrentRenameAndWait(tor, "Felidae/Felinae/Felis/catus/placeholder", "Kyphi"), ==, 0);
check_str(files[1].name, ==, "Felidae/Felinae/Felis/catus/Kyphi");
testFileExistsAndConsistsOfThisString(tor, 1, "Inquisitive\n");
/* rename a branch... */
- check_int_eq(0, torrentRenameAndWait(tor, "Felidae/Felinae/Felis/catus", "placeholder"));
+ check_int(torrentRenameAndWait(tor, "Felidae/Felinae/Felis/catus", "placeholder"), ==, 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");
check_str(files[3].name, ==, expected_files[3]);
/* ...and back again */
- check_int_eq(0, torrentRenameAndWait(tor, "Felidae/Felinae/Felis/placeholder", "catus"));
+ check_int(torrentRenameAndWait(tor, "Felidae/Felinae/Felis/placeholder", "catus"), ==, 0);
for (tr_file_index_t i = 0; i < 4; ++i)
{
testFileExistsAndConsistsOfThisString(tor, 3, expected_contents[3]);
/* rename a branch... */
- check_int_eq(0, torrentRenameAndWait(tor, "Felidae/Felinae/Felis/catus", "foo"));
+ check_int(torrentRenameAndWait(tor, "Felidae/Felinae/Felis/catus", "foo"), ==, 0);
check_str(files[0].name, ==, expected_files[0]);
check_str(files[1].name, ==, "Felidae/Felinae/Felis/foo/Kyphi");
check_str(files[2].name, ==, "Felidae/Felinae/Felis/foo/Saffron");
check_str(files[3].name, ==, expected_files[3]);
/* ...and back again */
- check_int_eq(0, torrentRenameAndWait(tor, "Felidae/Felinae/Felis/foo", "catus"));
+ check_int(torrentRenameAndWait(tor, "Felidae/Felinae/Felis/foo", "catus"), ==, 0);
for (tr_file_index_t i = 0; i < 4; ++i)
{
check_str(files[i].name, ==, expected_files[i]);
}
- check_int_eq(0, torrentRenameAndWait(tor, "Felidae", "gabba"));
+ check_int(torrentRenameAndWait(tor, "Felidae", "gabba"), ==, 0);
strings[0] = "gabba/Felinae/Acinonyx/Cheetah/Chester";
strings[1] = "gabba/Felinae/Felis/catus/Kyphi";
strings[2] = "gabba/Felinae/Felis/catus/Saffron";
}
/* rename the root, then a branch, and then a leaf... */
- check_int_eq(0, torrentRenameAndWait(tor, "gabba", "Felidae"));
- check_int_eq(0, torrentRenameAndWait(tor, "Felidae/Pantherinae/Panthera/Tiger", "Snow Leopard"));
- check_int_eq(0, torrentRenameAndWait(tor, "Felidae/Pantherinae/Panthera/Snow Leopard/Tony", "10.6"));
+ check_int(torrentRenameAndWait(tor, "gabba", "Felidae"), ==, 0);
+ check_int(torrentRenameAndWait(tor, "Felidae/Pantherinae/Panthera/Tiger", "Snow Leopard"), ==, 0);
+ check_int(torrentRenameAndWait(tor, "Felidae/Pantherinae/Panthera/Snow Leopard/Tony", "10.6"), ==, 0);
strings[0] = "Felidae/Felinae/Acinonyx/Cheetah/Chester";
strings[1] = "Felidae/Felinae/Felis/catus/Kyphi";
strings[2] = "Felidae/Felinae/Felis/catus/Saffron";
files = tor->info.files;
/* rename prefix of top */
- check_int_eq(EINVAL, torrentRenameAndWait(tor, "Feli", "FelidaeX"));
+ check_int(torrentRenameAndWait(tor, "Feli", "FelidaeX"), ==, EINVAL);
check_str(tor->info.name, ==, "Felidae");
check(!files[0].is_renamed);
check(!files[1].is_renamed);
check(!files[3].is_renamed);
/* rename false path */
- check_int_eq(EINVAL, torrentRenameAndWait(tor, "Felidae/FelinaeX", "Genus Felinae"));
+ check_int(torrentRenameAndWait(tor, "Felidae/FelinaeX", "Genus Felinae"), ==, EINVAL);
check_str(tor->info.name, ==, "Felidae");
check(!files[0].is_renamed);
check(!files[1].is_renamed);
****
***/
- check_int_eq(0, torrentRenameAndWait(tor, "files-filled-with-zeroes", "foo"));
- check_int_eq(0, torrentRenameAndWait(tor, "foo/1048576", "bar"));
+ check_int(torrentRenameAndWait(tor, "files-filled-with-zeroes", "foo"), ==, 0);
+ check_int(torrentRenameAndWait(tor, "foo/1048576", "bar"), ==, 0);
strings[0] = "foo/bar";
strings[1] = "foo/4096";
strings[2] = "foo/512";
tr_rpc_parse_list_str(&top, "12", TR_BAD_SIZE);
check(tr_variantIsInt(&top));
check(tr_variantGetInt(&top, &i));
- check_int_eq(12, i);
+ check_int(i, ==, 12);
tr_variantFree(&top);
tr_rpc_parse_list_str(&top, "12", 1);
check(tr_variantIsInt(&top));
check(tr_variantGetInt(&top, &i));
- check_int_eq(1, i);
+ check_int(i, ==, 1);
tr_variantFree(&top);
tr_rpc_parse_list_str(&top, "6,7", TR_BAD_SIZE);
check(tr_variantIsList(&top));
check(tr_variantListSize(&top) == 2);
check(tr_variantGetInt(tr_variantListChild(&top, 0), &i));
- check_int_eq(6, i);
+ check_int(i, ==, 6);
check(tr_variantGetInt(tr_variantListChild(&top, 1), &i));
- check_int_eq(7, i);
+ check_int(i, ==, 7);
tr_variantFree(&top);
tr_rpc_parse_list_str(&top, "asdf", TR_BAD_SIZE);
check(tr_variantIsList(&top));
check(tr_variantListSize(&top) == 4);
check(tr_variantGetInt(tr_variantListChild(&top, 0), &i));
- check_int_eq(1, i);
+ check_int(i, ==, 1);
check(tr_variantGetInt(tr_variantListChild(&top, 1), &i));
- check_int_eq(3, i);
+ check_int(i, ==, 3);
check(tr_variantGetInt(tr_variantListChild(&top, 2), &i));
- check_int_eq(4, i);
+ check_int(i, ==, 4);
check(tr_variantGetInt(tr_variantListChild(&top, 3), &i));
- check_int_eq(5, i);
+ check_int(i, ==, 5);
tr_variantFree(&top);
return 0;
while ((c = tr_getopt("summary", argc, argv, options, &optarg)) != TR_OPT_DONE)
{
check(n < expected_n);
- check_int_eq(expected_c[n], c);
+ check_int(c, ==, expected_c[n]);
check_str(optarg, ==, expected_optarg[n]);
++n;
}
- check_int_eq(expected_n, n);
+ check_int(n, ==, expected_n);
return 0;
}
int* numbers;
numbers = tr_parseNumberRange("1-10,13,16-19", TR_BAD_SIZE, &count);
- check_int_eq(15, count);
- check_int_eq(1, numbers[0]);
- check_int_eq(6, numbers[5]);
- check_int_eq(10, numbers[9]);
- check_int_eq(13, numbers[10]);
- check_int_eq(16, numbers[11]);
- check_int_eq(19, numbers[14]);
+ check_int(count, ==, 15);
+ check_int(numbers[0], ==, 1);
+ check_int(numbers[5], ==, 6);
+ check_int(numbers[9], ==, 10);
+ check_int(numbers[10], ==, 13);
+ check_int(numbers[11], ==, 16);
+ check_int(numbers[14], ==, 19);
tr_free(numbers);
numbers = tr_parseNumberRange("1-5,3-7,2-6", TR_BAD_SIZE, &count);
for (int i = 0; i < count; ++i)
{
- check_int_eq(i + 1, numbers[i]);
+ check_int(numbers[i], ==, i + 1);
}
tr_free(numbers);
numbers = tr_parseNumberRange("1-Hello", TR_BAD_SIZE, &count);
- check_int_eq(0, count);
+ check_int(count, ==, 0);
check(numbers == NULL);
numbers = tr_parseNumberRange("1-", TR_BAD_SIZE, &count);
- check_int_eq(0, count);
+ check_int(count, ==, 0);
check(numbers == NULL);
numbers = tr_parseNumberRange("Hello", TR_BAD_SIZE, &count);
- check_int_eq(0, count);
+ check_int(count, ==, 0);
check(numbers == NULL);
return 0;
#endif
- check_int_eq(expected_pos[i - 1], pos);
- check_int_eq(expected_exact[i - 1], exact);
+ check_int(pos, ==, expected_pos[i - 1]);
+ check_int(exact, ==, expected_exact[i - 1]);
}
return 0;
for (size_t i = 0; i < n_trials; ++i)
{
- check_int_eq(0, test_quickFindFirst_Iteration(k, n, buf, 100));
+ check_int(test_quickFindFirst_Iteration(k, n, buf, 100), ==, 0);
}
tr_free(buf);
for (size_t i = 0; i < n; ++i)
{
- check_int_eq(i < 5 ? i : i + 1, array[i]);
+ check_int(array[i], ==, i < 5 ? i : i + 1);
}
tr_removeElementFromArray(array, 0u, sizeof(size_t), n--);
for (size_t i = 0; i < n; ++i)
{
- check_int_eq(i < 4 ? i + 1 : i + 2, array[i]);
+ check_int(array[i], ==, i < 4 ? i + 1 : i + 2);
}
tr_removeElementFromArray(array, n - 1, sizeof(size_t), n);
for (size_t i = 0; i < n; ++i)
{
- check_int_eq(i < 4 ? i + 1 : i + 2, array[i]);
+ check_int(array[i], ==, i < 4 ? i + 1 : i + 2);
}
return 0;
check_str(scheme, ==, "http");
check_str(host, ==, "1");
check_str(path, ==, "/");
- check_int_eq(80, port);
+ check_int(port, ==, 80);
tr_free(scheme);
tr_free(path);
tr_free(host);
check_str(scheme, ==, "http");
check_str(host, ==, "www.some-tracker.org");
check_str(path, ==, "/some/path");
- check_int_eq(80, port);
+ check_int(port, ==, 80);
tr_free(scheme);
tr_free(path);
tr_free(host);
check_str(scheme, ==, "http");
check_str(host, ==, "www.some-tracker.org");
check_str(path, ==, "/some/path");
- check_int_eq(80, port);
+ check_int(port, ==, 80);
tr_free(scheme);
tr_free(path);
tr_free(host);
check(!tr_env_key_exists(test_key));
x = tr_env_get_int(test_key, 123);
- check_int_eq(123, x);
+ check_int(x, ==, 123);
s = tr_env_get_string(test_key, NULL);
check(s == NULL);
s = tr_env_get_string(test_key, "a");
check(tr_env_key_exists(test_key));
x = tr_env_get_int(test_key, 456);
- check_int_eq(456, x);
+ check_int(x, ==, 456);
s = tr_env_get_string(test_key, NULL);
check_str(s, ==, "");
tr_free(s);
check(tr_env_key_exists(test_key));
x = tr_env_get_int(test_key, 789);
- check_int_eq(135, x);
+ check_int(x, ==, 135);
s = tr_env_get_string(test_key, NULL);
check_str(s, ==, "135");
tr_free(s);
/* good int string */
tr_snprintf((char*)buf, sizeof(buf), "i64e");
err = tr_bencParseInt(buf, buf + 4, &end, &val);
- check_int_eq(0, err);
- check_int_eq(64, val);
+ check_int(err, ==, 0);
+ check_int(val, ==, 64);
check(buf + 4 == end);
/* missing 'e' */
end = NULL;
val = 888;
err = tr_bencParseInt(buf, buf + 3, &end, &val);
- check_int_eq(EILSEQ, err);
- check_int_eq(888, val);
+ check_int(err, ==, EILSEQ);
+ check_int(val, ==, 888);
check(end == NULL);
/* empty buffer */
err = tr_bencParseInt(buf, buf + 0, &end, &val);
- check_int_eq(EILSEQ, err);
- check_int_eq(888, val);
+ check_int(err, ==, EILSEQ);
+ check_int(val, ==, 888);
check(end == NULL);
/* bad number */
tr_snprintf((char*)buf, sizeof(buf), "i6z4e");
err = tr_bencParseInt(buf, buf + 5, &end, &val);
- check_int_eq(EILSEQ, err);
- check_int_eq(888, val);
+ check_int(err, ==, EILSEQ);
+ check_int(val, ==, 888);
check(end == NULL);
/* negative number */
tr_snprintf((char*)buf, sizeof(buf), "i-3e");
err = tr_bencParseInt(buf, buf + 4, &end, &val);
- check_int_eq(0, err);
- check_int_eq(-3, val);
+ check_int(err, ==, 0);
+ check_int(val, ==, -3);
check(buf + 4 == end);
/* zero */
tr_snprintf((char*)buf, sizeof(buf), "i0e");
err = tr_bencParseInt(buf, buf + 4, &end, &val);
- check_int_eq(0, err);
- check_int_eq(0, val);
+ check_int(err, ==, 0);
+ check_int(val, ==, 0);
check(buf + 3 == end);
/* no leading zeroes allowed */
end = NULL;
tr_snprintf((char*)buf, sizeof(buf), "i04e");
err = tr_bencParseInt(buf, buf + 4, &end, &val);
- check_int_eq(EILSEQ, err);
- check_int_eq(0, val);
+ check_int(err, ==, EILSEQ);
+ check_int(val, ==, 0);
check(NULL == end);
return 0;
/* string len is designed to overflow */
n = tr_snprintf((char*)buf, sizeof(buf), "%zu:boat", (size_t)(SIZE_MAX - 2));
err = tr_bencParseStr(buf, buf + n, &end, &str, &len);
- check_int_eq(EILSEQ, err);
+ check_int(err, ==, EILSEQ);
check_uint_eq(0, len);
check(str == NULL);
check(end == NULL);
/* good string */
n = tr_snprintf((char*)buf, sizeof(buf), "4:boat");
err = tr_bencParseStr(buf, buf + n, &end, &str, &len);
- check_int_eq(0, err);
+ check_int(err, ==, 0);
check_uint_eq(4, len);
check(strncmp((char const*)str, "boat", len) == 0);
check(end == buf + 6);
/* string goes past end of buffer */
err = tr_bencParseStr(buf, buf + (n - 1), &end, &str, &len);
- check_int_eq(EILSEQ, err);
+ check_int(err, ==, EILSEQ);
check_uint_eq(0, len);
check(str == NULL);
check(end == NULL);
/* empty string */
n = tr_snprintf((char*)buf, sizeof(buf), "0:");
err = tr_bencParseStr(buf, buf + n, &end, &str, &len);
- check_int_eq(0, err);
+ check_int(err, ==, 0);
check_uint_eq(0, len);
check(*str == '\0');
check(end == buf + 2);
/* short string */
n = tr_snprintf((char*)buf, sizeof(buf), "3:boat");
err = tr_bencParseStr(buf, buf + n, &end, &str, &len);
- check_int_eq(0, err);
+ check_int(err, ==, 0);
check_uint_eq(3, len);
check(strncmp((char const*)str, "boa", len) == 0);
check(end == buf + 5);
err = tr_variantFromBencFull(&val, buf, sizeof(buf), NULL, &end);
check(err == 0);
check(tr_variantGetInt(&val, &i));
- check_int_eq(64, i);
+ check_int(i, ==, 64);
check(end == buf + 4);
tr_variantFree(&val);
check(end == buf + strlen((char*)buf));
check(val.val.l.count == 3);
check(tr_variantGetInt(&val.val.l.vals[0], &i));
- check_int_eq(64, i);
+ check_int(i, ==, 64);
check(tr_variantGetInt(&val.val.l.vals[1], &i));
- check_int_eq(32, i);
+ check_int(i, ==, 32);
check(tr_variantGetInt(&val.val.l.vals[2], &i));
- check_int_eq(16, i);
+ check_int(i, ==, 16);
saved = tr_variantToStr(&val, TR_VARIANT_FMT_BENC, &len);
check_str(saved, ==, buf);
tr_free(saved);
tr_variantMergeDicts(&dest, /*const*/ &src);
check(tr_variantDictFindInt(&dest, i1, &i));
- check_int_eq(1, i);
+ check_int(i, ==, 1);
check(tr_variantDictFindInt(&dest, i2, &i));
- check_int_eq(4, i);
+ check_int(i, ==, 4);
check(tr_variantDictFindInt(&dest, i3, &i));
- check_int_eq(3, i);
+ check_int(i, ==, 3);
check(tr_variantDictFindInt(&dest, i4, &i));
- check_int_eq(-35, i);
+ check_int(i, ==, -35);
check(tr_variantDictFindStr(&dest, s5, &s, &len));
check_uint_eq(3, len);
check_str(s, ==, "abc");
in[depth * 2] = '\0';
err = tr_variantFromBencFull(&val, in, depth * 2, NULL, &end);
- check_int_eq(0, err);
+ check_int(err, ==, 0);
check(end == in + depth * 2);
saved = tr_variantToStr(&val, TR_VARIANT_FMT_BENC, &len);
check_str(saved, ==, in);
check(end == benc + len);
check(tr_variantIsDict(&top2));
check(tr_variantDictFindInt(&top, key_int, &intVal));
- check_int_eq(1234, intVal);
+ check_int(intVal, ==, 1234);
check(tr_variantDictFindBool(&top, key_bool, &boolVal));
check(boolVal == true);
check(tr_variantDictFindStr(&top, key_str, &strVal, &strLen));
check_uint_eq(16, strLen);
check_str(strVal, ==, "this-is-a-string");
check(tr_variantDictFindReal(&top, key_real, &realVal));
- check_int_eq(50, (int)(realVal * 100));
+ check_int((int)(realVal * 100), ==, 50);
tr_variantFree(&top2);
tr_free(benc);