#define TEST_CLIENT(A, B) \
tr_clientForId(buf, sizeof(buf), A); \
- check_streq(B, buf);
+ check_str_eq(B, buf);
int main(void)
{
tr_cryptoEncrypt(&a, sizeof(test1), test1, buf11);
tr_cryptoDecryptInit_(&b);
tr_cryptoDecrypt_(&b, sizeof(test1), buf11, buf12);
- check_streq(test1, buf12);
+ check_str_eq(test1, buf12);
tr_cryptoEncryptInit_(&b);
tr_cryptoEncrypt_(&b, sizeof(test2), test2, buf21);
tr_cryptoDecryptInit(&a);
tr_cryptoDecrypt(&a, sizeof(test2), buf21, buf22);
- check_streq(test2, buf22);
+ check_str_eq(test2, buf22);
tr_cryptoDestruct_(&b);
tr_cryptoDestruct(&a);
check(base64_eq("WU9ZTyE=", out));
in = tr_base64_decode_str(out, &len);
check_uint_eq(5, len);
- check_streq("YOYO!", in);
+ check_str_eq("YOYO!", in);
tr_free(in);
tr_free(out);
out = tr_base64_encode("", 0, &len);
check_uint_eq(0, len);
- check_streq("", out);
+ check_str_eq("", out);
tr_free(out);
out = tr_base64_decode("", 0, &len);
check_uint_eq(0, len);
- check_streq("", out);
+ check_str_eq("", out);
tr_free(out);
out = tr_base64_encode(NULL, 0, &len);
check_uint_eq(strlen(out), len);
in = tr_base64_decode_str(out, &len);
check_uint_eq(i, len);
- check_streq(in, buf);
+ check_str_eq(in, buf);
tr_free(in);
tr_free(out);
}
tr_error_set(&err, 1, "error: %s (%d)", "oops", 2);
check(err != NULL);
check_int_eq(1, err->code);
- check_streq("error: oops (2)", err->message);
+ check_str_eq("error: oops (2)", err->message);
tr_error_clear(&err);
check(err == NULL);
tr_error_set_literal(&err, 2, "oops");
check(err != NULL);
check_int_eq(2, err->code);
- check_streq("oops", err->message);
+ check_str_eq("oops", err->message);
tr_error_prefix(&err, "error: ");
check(err != NULL);
check_int_eq(2, err->code);
- check_streq("error: oops", err->message);
+ check_str_eq("error: oops", err->message);
tr_error_free(err);
tr_error_set_literal(&err, 1, "oops");
check(err != NULL);
check_int_eq(1, err->code);
- check_streq("oops", err->message);
+ check_str_eq("oops", err->message);
tr_error_propagate(&err2, &err);
check(err2 != NULL);
check_int_eq(1, err2->code);
- check_streq("oops", err2->message);
+ check_str_eq("oops", err2->message);
check(err == NULL);
tr_error_propagate_prefixed(&err, &err2, "error: ");
check(err != NULL);
check_int_eq(1, err->code);
- check_streq("error: oops", err->message);
+ check_str_eq("error: oops", err->message);
check(err2 == NULL);
tr_error_propagate(NULL, &err);
{
check(name != NULL);
check(err == NULL);
- check_streq(data[i].output, name);
+ check_str_eq(data[i].output, name);
tr_free(name);
}
else
check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
check(err == NULL);
- check_streq("a", buffer);
+ check_str_eq("a", buffer);
check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
check(err == NULL);
- check_streq("bc", buffer);
+ check_str_eq("bc", buffer);
check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
check(err == NULL);
- check_streq("def", buffer);
+ check_str_eq("def", buffer);
check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
check(err == NULL);
- check_streq("ghij", buffer);
+ check_str_eq("ghij", buffer);
check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
check(err == NULL);
- check_streq("", buffer);
+ check_str_eq("", buffer);
check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
check(err == NULL);
- check_streq("", buffer);
+ check_str_eq("", buffer);
check(tr_sys_file_read_line(fd, buffer, 4, &err));
check(err == NULL);
- check_streq("klmn", buffer);
+ check_str_eq("klmn", buffer);
check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
check(err == NULL);
- check_streq("o", buffer);
+ check_str_eq("o", buffer);
check(!tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
check(err == NULL);
- check_streq("o", buffer); /* on EOF, buffer stays unchanged */
+ check_str_eq("o", buffer); /* on EOF, buffer stays unchanged */
tr_sys_file_close(fd, NULL);
check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
check(err == NULL);
- check_streq("p", buffer);
+ check_str_eq("p", buffer);
check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
check(err == NULL);
- check_streq("", buffer);
+ check_str_eq("", buffer);
check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
check(err == NULL);
- check_streq("qr", buffer);
+ check_str_eq("qr", buffer);
check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
check(err == NULL);
- check_streq("stu", buffer);
+ check_str_eq("stu", buffer);
check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
check(err == NULL);
- check_streq("", buffer);
+ check_str_eq("", buffer);
check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
check(err == NULL);
- check_streq("", buffer);
+ check_str_eq("", buffer);
check(tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
check(err == NULL);
- check_streq("vwxy2", buffer);
+ check_str_eq("vwxy2", buffer);
check(!tr_sys_file_read_line(fd, buffer, TR_N_ELEMENTS(buffer), &err));
check(err == NULL);
- check_streq("vwxy2", buffer); /* on EOF, buffer stays unchanged */
+ check_str_eq("vwxy2", buffer); /* on EOF, buffer stays unchanged */
tr_sys_file_close(fd, NULL);
str = NULL;
key = tr_quark_new("string", 6);
check(tr_variantDictFindStr(&top, key, &str, NULL));
- check_streq("hello world", str);
+ check_str_eq("hello world", str);
check(tr_variantDictFindStr(&top, tr_quark_new("escaped", 7), &str, NULL));
- check_streq("bell \b formfeed \f linefeed \n carriage return \r tab \t", str);
+ check_str_eq("bell \b formfeed \f linefeed \n carriage return \r tab \t", str);
i = 0;
check(tr_variantDictFindInt(&top, tr_quark_new("int", 3), &i));
check_int_eq(5, i);
check(tr_variantDictFindBool(&top, tr_quark_new("false", 5), &f));
check_int_eq(false, f);
check(tr_variantDictFindStr(&top, tr_quark_new("null", 4), &str, NULL));
- check_streq("", str);
+ check_str_eq("", str);
if (err == 0)
{
check(err == 0);
check(tr_variantIsDict(&top));
check(tr_variantDictFindStr(&top, key, &str, NULL));
- check_streq("Letöltések", str);
+ check_str_eq("Letöltések", str);
if (err == 0)
{
check(err == 0);
check(tr_variantIsDict(&top));
check(tr_variantDictFindStr(&top, key, &str, NULL));
- check_streq("\\", str);
+ check_str_eq("\\", str);
if (err == 0)
{
check(err == 0);
check(tr_variantIsDict(&top));
check(tr_variantDictFindStr(&top, key, &str, NULL));
- check_streq("Letöltések", str);
+ check_str_eq("Letöltések", str);
json = tr_variantToStr(&top, TR_VARIANT_FMT_JSON, NULL);
if (err == 0)
check(err == 0);
check(tr_variantIsDict(&top));
check(tr_variantDictFindStr(&top, key, &str, NULL));
- check_streq("Letöltések", str);
+ check_str_eq("Letöltések", str);
if (err == 0)
{
check((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_streq("request", str);
+ check_str_eq("request", str);
check(tr_variantDictFindInt(headers, TR_KEY_tag, &i));
check_int_eq(666, i);
check((body = tr_variantDictFind(&top, tr_quark_new("body", 4))) != NULL);
check(tr_variantDictFindStr(body, TR_KEY_name, &str, NULL));
- check_streq("torrent-info", str);
+ check_str_eq("torrent-info", str);
check((args = tr_variantDictFind(body, tr_quark_new("arguments", 9))) != NULL);
check(tr_variantIsDict(args));
check((ids = tr_variantDictFind(args, TR_KEY_ids)) != NULL);
int const err = tr_variantFromJson(&top, in, strlen(in));
check(err == 0);
check(tr_variantDictFindStr(&top, TR_KEY_errorString, &str, NULL));
- check_streq("torrent not registered with this tracker 6UHsVW'*C", str);
+ check_str_eq("torrent not registered with this tracker 6UHsVW'*C", str);
tr_variantFree(&top);
return 0;
int const err = tr_variantFromJson(&top, in, strlen(in));
check_int_eq(0, err);
check(tr_variantDictFindStr(&top, tr_quark_new("string-1", 8), &str, NULL));
- check_streq("/usr/lib", str);
+ check_str_eq("/usr/lib", str);
tr_variantFree(&top);
return 0;
return pass;
}
-bool check_streq_impl(char const* file, int line, char const* expected, char const* actual)
+bool check_str_eq_impl(char const* file, int line, char const* expected, char const* actual)
{
bool const pass = tr_strcmp0(expected, actual) == 0;
bool check_int_eq_impl(char const* file, int line, int64_t expected, int64_t actual);
bool check_uint_eq_impl(char const* file, int line, uint64_t expected, uint64_t actual);
bool check_ptr_eq_impl(char const* file, int line, void const* expected, void const* actual);
-bool check_streq_impl(char const* file, int line, char const* expected, char const* actual);
+bool check_str_eq_impl(char const* file, int line, char const* expected, char const* actual);
/***
****
} \
while (0)
-#define check_streq(expected, actual) \
+#define check_str_eq(expected, actual) \
do \
{ \
++current_test; \
\
- if (!check_streq_impl(__FILE__, __LINE__, (expected), (actual))) \
+ if (!check_str_eq_impl(__FILE__, __LINE__, (expected), (actual))) \
{ \
return current_test; \
} \
info = tr_magnetParse(uri);
check(info != NULL);
check_int_eq(2, info->trackerCount);
- check_streq(info->trackers[0], "http://tracker.openbittorrent.com/announce");
- check_streq(info->trackers[1], "http://tracker.opentracker.org/announce");
+ check_str_eq(info->trackers[0], "http://tracker.openbittorrent.com/announce");
+ check_str_eq(info->trackers[1], "http://tracker.opentracker.org/announce");
check_int_eq(1, info->webseedCount);
- check_streq("http://server.webseed.org/path/to/file", info->webseeds[0]);
- check_streq("Display Name", info->displayName);
+ check_str_eq("http://server.webseed.org/path/to/file", info->webseeds[0]);
+ check_str_eq("Display Name", info->displayName);
for (int i = 0; i < 20; ++i)
{
info = tr_magnetParse(uri);
check(info != NULL);
check_int_eq(2, info->trackerCount);
- check_streq("http://tracker.openbittorrent.com/announce", info->trackers[0]);
- check_streq("http://tracker.opentracker.org/announce", info->trackers[1]);
+ check_str_eq("http://tracker.openbittorrent.com/announce", info->trackers[0]);
+ check_str_eq("http://tracker.opentracker.org/announce", info->trackers[1]);
check_int_eq(1, info->webseedCount);
- check_streq("http://server.webseed.org/path/to/file", info->webseeds[0]);
- check_streq("Display Name", info->displayName);
+ check_str_eq("http://server.webseed.org/path/to/file", info->webseeds[0]);
+ check_str_eq("Display Name", info->displayName);
for (int i = 0; i < 20; ++i)
{
input_file = tr_buildPath(sandbox, "test.XXXXXX", NULL);
libtest_create_tmpfile_with_contents(input_file, payload, payloadSize);
builder = tr_metaInfoBuilderCreate(input_file);
- check_streq(input_file, builder->top);
+ check_str_eq(input_file, builder->top);
check_int_eq(1, builder->fileCount);
- check_streq(input_file, builder->files[0].filename);
+ check_str_eq(input_file, builder->files[0].filename);
check_int_eq(payloadSize, builder->files[0].size);
check_int_eq(payloadSize, builder->totalSize);
check(!builder->isFolder);
torrent_file = tr_strdup_printf("%s.torrent", input_file);
tr_makeMetaInfo(builder, torrent_file, trackers, trackerCount, comment, isPrivate);
check(isPrivate == builder->isPrivate);
- check_streq(torrent_file, builder->outputFile);
- check_streq(comment, builder->comment);
+ check_str_eq(torrent_file, builder->outputFile);
+ check_str_eq(comment, builder->comment);
check_int_eq(trackerCount, builder->trackerCount);
while (!builder->isDone)
/* quick check of some of the parsed metainfo */
check_int_eq(payloadSize, inf.totalSize);
tmpstr = tr_sys_path_basename(input_file, NULL);
- check_streq(tmpstr, inf.name);
+ check_str_eq(tmpstr, inf.name);
tr_free(tmpstr);
- check_streq(comment, inf.comment);
+ check_str_eq(comment, inf.comment);
check_int_eq(1, inf.fileCount);
check_int_eq(isPrivate, inf.isPrivate);
check(!inf.isFolder);
/* init the builder */
builder = tr_metaInfoBuilderCreate(top);
check(!builder->abortFlag);
- check_streq(top, builder->top);
+ check_str_eq(top, builder->top);
check_int_eq(payloadCount, builder->fileCount);
check_int_eq(totalSize, builder->totalSize);
check(builder->isFolder);
for (size_t i = 0; i < builder->fileCount; i++)
{
- check_streq(files[i], builder->files[i].filename);
+ check_str_eq(files[i], builder->files[i].filename);
check_int_eq(payloadSizes[i], builder->files[i].size);
}
torrent_file = tr_strdup_printf("%s.torrent", top);
tr_makeMetaInfo(builder, torrent_file, trackers, trackerCount, comment, isPrivate);
check(isPrivate == builder->isPrivate);
- check_streq(torrent_file, builder->outputFile);
- check_streq(comment, builder->comment);
+ check_str_eq(torrent_file, builder->outputFile);
+ check_str_eq(comment, builder->comment);
check_int_eq(trackerCount, builder->trackerCount);
while (!builder->isDone)
/* quick check of some of the parsed metainfo */
check_int_eq(totalSize, inf.totalSize);
tmpstr = tr_sys_path_basename(top, NULL);
- check_streq(tmpstr, inf.name);
+ check_str_eq(tmpstr, inf.name);
tr_free(tmpstr);
- check_streq(comment, inf.comment);
+ check_str_eq(comment, inf.comment);
check_int_eq(payloadCount, inf.fileCount);
check_int_eq(isPrivate, inf.isPrivate);
check_int_eq(builder->isFolder, inf.isFolder);
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_streq("http://tracker.publicbt.com/announce", inf.trackers[0].announce);
- check_streq("udp://tracker.publicbt.com:80", inf.trackers[1].announce);
+ check_str_eq("http://tracker.publicbt.com/announce", inf.trackers[0].announce);
+ check_str_eq("udp://tracker.publicbt.com:80", inf.trackers[1].announce);
check_int_eq(inf.webseedCount, 1);
- check_streq("http://transmissionbt.com", inf.webseeds[0]);
+ check_str_eq("http://transmissionbt.com", inf.webseeds[0]);
/* cleanup */
tr_metainfoFree(&inf);
{ \
char* path = tr_torrentFindFile(tor, i); \
char* expected = expected_path; \
- check_streq(expected, path); \
+ check_str_eq(expected, path); \
tr_free(expected); \
tr_free(path); \
} \
tr_quark const q = tr_quark_new(NULL, TR_BAD_SIZE);
check_int_eq(TR_KEY_NONE, (int)q);
- check_streq("", tr_quark_get_string(q, NULL));
+ check_str_eq("", tr_quark_get_string(q, NULL));
return 0;
}
/* sanity check the info */
check_int_eq(1, tor->info.fileCount);
- check_streq("hello-world.txt", tor->info.files[0].name);
+ check_str_eq("hello-world.txt", tor->info.files[0].name);
check(!tor->info.files[0].is_renamed);
/* sanity check the (empty) stats */
check_int_eq(EINVAL, torrentRenameAndWait(tor, "hello-world.txt", "hello/world.txt"));
check(!tor->info.files[0].is_renamed);
- check_streq("hello-world.txt", tor->info.files[0].name);
+ check_str_eq("hello-world.txt", tor->info.files[0].name);
/***
**** Now try a rename that should succeed
tmpstr = tr_buildPath(tor->currentDir, "hello-world.txt", NULL);
check(tr_sys_path_exists(tmpstr, NULL));
- check_streq("hello-world.txt", tr_torrentName(tor));
+ check_str_eq("hello-world.txt", tr_torrentName(tor));
check_int_eq(0, torrentRenameAndWait(tor, tor->info.name, "foobar"));
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 */
- check_streq("foobar", tr_torrentName(tor)); /* confirm the torrent's name is now 'foobar' */
- check_streq("foobar", tor->info.files[0].name); /* confirm the file's name is now 'foobar' in our struct */
+ check_str_eq("foobar", tr_torrentName(tor)); /* confirm the torrent's name is now 'foobar' */
+ check_str_eq("foobar", tor->info.files[0].name); /* 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 */
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_torrentSaveResume(tor);
libttest_sync();
loaded = tr_torrentLoadResume(tor, ~0, ctor);
- check_streq("foobar", tr_torrentName(tor));
+ check_str_eq("foobar", tr_torrentName(tor));
check((loaded & TR_FR_NAME) != 0);
/***
check_int_eq(0, torrentRenameAndWait(tor, "foobar", "hello-world.txt"));
check(!tr_sys_path_exists(tmpstr, NULL));
check(tor->info.files[0].is_renamed);
- check_streq("hello-world.txt", tor->info.files[0].name);
- check_streq("hello-world.txt", tr_torrentName(tor));
+ check_str_eq("hello-world.txt", tor->info.files[0].name);
+ check_str_eq("hello-world.txt", tr_torrentName(tor));
tr_free(tmpstr);
check(testFileExistsAndConsistsOfThisString(tor, 0, "hello, world!\n"));
files = tor->info.files;
/* sanity check the info */
- check_streq(tor->info.name, "Felidae");
+ check_str_eq(tor->info.name, "Felidae");
check_uint_eq(totalSize, tor->info.totalSize);
check_uint_eq(4, tor->info.fileCount);
for (tr_file_index_t i = 0; i < 4; ++i)
{
- check_streq(expected_files[i], files[i].name);
+ check_str_eq(expected_files[i], files[i].name);
}
/* sanity check the (empty) stats */
/* rename a leaf... */
check_int_eq(0, torrentRenameAndWait(tor, "Felidae/Felinae/Felis/catus/Kyphi", "placeholder"));
- check_streq(files[1].name, "Felidae/Felinae/Felis/catus/placeholder");
+ check_str_eq(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_streq(files[1].name, "Felidae/Felinae/Felis/catus/Kyphi");
+ check_str_eq(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_streq(expected_files[0], files[0].name);
- check_streq("Felidae/Felinae/Felis/placeholder/Kyphi", files[1].name);
- check_streq("Felidae/Felinae/Felis/placeholder/Saffron", files[2].name);
- check_streq(expected_files[3], files[3].name);
+ check_str_eq(expected_files[0], files[0].name);
+ check_str_eq("Felidae/Felinae/Felis/placeholder/Kyphi", files[1].name);
+ check_str_eq("Felidae/Felinae/Felis/placeholder/Saffron", files[2].name);
+ check_str_eq(expected_files[3], files[3].name);
check(testFileExistsAndConsistsOfThisString(tor, 1, expected_contents[1]));
check(testFileExistsAndConsistsOfThisString(tor, 2, expected_contents[2]));
check(!files[0].is_renamed);
tor->info.files[1].name = tr_strdup("gabba gabba hey");
loaded = tr_torrentLoadResume(tor, ~0, ctor);
check((loaded & TR_FR_FILENAMES) != 0);
- check_streq(expected_files[0], files[0].name);
- check_streq("Felidae/Felinae/Felis/placeholder/Kyphi", files[1].name);
- check_streq("Felidae/Felinae/Felis/placeholder/Saffron", files[2].name);
- check_streq(expected_files[3], files[3].name);
+ check_str_eq(expected_files[0], files[0].name);
+ check_str_eq("Felidae/Felinae/Felis/placeholder/Kyphi", files[1].name);
+ check_str_eq("Felidae/Felinae/Felis/placeholder/Saffron", files[2].name);
+ check_str_eq(expected_files[3], files[3].name);
/* ...and back again */
check_int_eq(0, torrentRenameAndWait(tor, "Felidae/Felinae/Felis/placeholder", "catus"));
for (tr_file_index_t i = 0; i < 4; ++i)
{
- check_streq(expected_files[i], files[i].name);
+ check_str_eq(expected_files[i], files[i].name);
check(testFileExistsAndConsistsOfThisString(tor, i, expected_contents[i]));
}
for (tr_file_index_t i = 1; i <= 2; ++i)
{
str = tr_torrentFindFile(tor, i);
- check_streq(NULL, str);
+ check_str_eq(NULL, str);
tr_free(str);
}
/* rename a branch... */
check_int_eq(0, torrentRenameAndWait(tor, "Felidae/Felinae/Felis/catus", "foo"));
- check_streq(expected_files[0], files[0].name);
- check_streq("Felidae/Felinae/Felis/foo/Kyphi", files[1].name);
- check_streq("Felidae/Felinae/Felis/foo/Saffron", files[2].name);
- check_streq(expected_files[3], files[3].name);
+ check_str_eq(expected_files[0], files[0].name);
+ check_str_eq("Felidae/Felinae/Felis/foo/Kyphi", files[1].name);
+ check_str_eq("Felidae/Felinae/Felis/foo/Saffron", files[2].name);
+ check_str_eq(expected_files[3], files[3].name);
/* ...and back again */
check_int_eq(0, torrentRenameAndWait(tor, "Felidae/Felinae/Felis/foo", "catus"));
for (tr_file_index_t i = 0; i < 4; ++i)
{
- check_streq(expected_files[i], files[i].name);
+ check_str_eq(expected_files[i], files[i].name);
}
check_int_eq(0, torrentRenameAndWait(tor, "Felidae", "gabba"));
for (tr_file_index_t i = 0; i < 4; ++i)
{
- check_streq(strings[i], files[i].name);
+ check_str_eq(strings[i], files[i].name);
testFileExistsAndConsistsOfThisString(tor, i, expected_contents[i]);
}
for (tr_file_index_t i = 0; i < 4; ++i)
{
- check_streq(strings[i], files[i].name);
+ check_str_eq(strings[i], files[i].name);
testFileExistsAndConsistsOfThisString(tor, i, expected_contents[i]);
}
/* rename prefix of top */
check_int_eq(EINVAL, torrentRenameAndWait(tor, "Feli", "FelidaeX"));
- check_streq(tor->info.name, "Felidae");
+ check_str_eq(tor->info.name, "Felidae");
check(!files[0].is_renamed);
check(!files[1].is_renamed);
check(!files[2].is_renamed);
/* rename false path */
check_int_eq(EINVAL, torrentRenameAndWait(tor, "Felidae/FelinaeX", "Genus Felinae"));
- check_streq(tor->info.name, "Felidae");
+ check_str_eq(tor->info.name, "Felidae");
check(!files[0].is_renamed);
check(!files[1].is_renamed);
check(!files[2].is_renamed);
check_uint_eq(totalSize, tor->info.totalSize);
check_uint_eq(pieceSize, tor->info.pieceSize);
check_uint_eq(pieceCount, tor->info.pieceCount);
- check_streq("files-filled-with-zeroes/1048576", tor->info.files[0].name);
- check_streq("files-filled-with-zeroes/4096", tor->info.files[1].name);
- check_streq("files-filled-with-zeroes/512", tor->info.files[2].name);
+ check_str_eq("files-filled-with-zeroes/1048576", tor->info.files[0].name);
+ check_str_eq("files-filled-with-zeroes/4096", tor->info.files[1].name);
+ check_str_eq("files-filled-with-zeroes/512", tor->info.files[2].name);
libttest_zero_torrent_populate(tor, false);
fst = tr_torrentFiles(tor, NULL);
for (tr_file_index_t i = 0; i < 3; ++i)
{
- check_streq(strings[i], tor->info.files[i].name);
+ check_str_eq(strings[i], tor->info.files[i].name);
}
strings[0] = "foo/bar.part";
{
char* expected = tr_buildPath(tor->currentDir, strings[i], NULL);
char* path = tr_torrentFindFile(tor, i);
- check_streq(expected, path);
+ check_str_eq(expected, path);
tr_free(path);
tr_free(expected);
}
check(tr_variantIsString(&top));
check(tr_variantGetStr(&top, &str, &len));
check_uint_eq(4, len);
- check_streq("asdf", str);
+ check_str_eq("asdf", str);
tr_variantFree(&top);
tr_rpc_parse_list_str(&top, "1,3-5", TR_BAD_SIZE);
{
check(n < expected_n);
check_int_eq(expected_c[n], c);
- check_streq(optarg, expected_optarg[n]);
+ check_str_eq(optarg, expected_optarg[n]);
++n;
}
in = "Hello %1$s foo %2$.*f";
expected = "Hello %s foo %.*f";
out = tr_strip_positional_args(in);
- check_streq(expected, out);
+ check_str_eq(expected, out);
in = "Hello %1$'d foo %2$'f";
expected = "Hello %d foo %f";
out = tr_strip_positional_args(in);
- check_streq(expected, out);
+ check_str_eq(expected, out);
return 0;
}
in = tr_strdup(" test ");
out = tr_strstrip(in);
check(in == out);
- check_streq("test", out);
+ check_str_eq("test", out);
tr_free(in);
/* strstrip */
in = tr_strdup(" test test ");
out = tr_strstrip(in);
check(in == out);
- check_streq("test test", out);
+ check_str_eq("test test", out);
tr_free(in);
/* strstrip */
in = tr_strdup("test");
out = tr_strstrip(in);
check(in == out);
- check_streq("test", out);
+ check_str_eq("test", out);
tr_free(in);
return 0;
char* out;
out = tr_buildPath("foo", "bar", NULL);
- check_streq("foo" TR_PATH_DELIMITER_STR "bar", out);
+ check_str_eq("foo" TR_PATH_DELIMITER_STR "bar", out);
tr_free(out);
out = tr_buildPath("", "foo", "bar", NULL);
- check_streq(TR_PATH_DELIMITER_STR "foo" TR_PATH_DELIMITER_STR "bar", out);
+ check_str_eq(TR_PATH_DELIMITER_STR "foo" TR_PATH_DELIMITER_STR "bar", out);
tr_free(out);
return 0;
in = "hello world";
out = tr_utf8clean(in, TR_BAD_SIZE);
- check_streq(in, out);
+ check_str_eq(in, out);
tr_free(out);
in = "hello world";
out = tr_utf8clean(in, 5);
- check_streq("hello", out);
+ check_str_eq("hello", out);
tr_free(out);
/* this version is not utf-8 (but cp866) */
out = tr_utf8clean(in, TR_BAD_SIZE);
check(out != NULL);
check(tr_utf8_validate(out, TR_BAD_SIZE, NULL));
- check_streq(in, out);
+ check_str_eq(in, out);
tr_free(out);
in = "\xF4\x00\x81\x82";
memcpy(hex1, "fb5ef5507427b17e04b69cef31fa3379b456735a", 41);
tr_hex_to_binary(hex1, binary, 20);
tr_binary_to_hex(binary, hex2, 20);
- check_streq(hex1, hex2);
+ check_str_eq(hex1, hex2);
return 0;
}
url = "http://1";
check(tr_urlParse(url, TR_BAD_SIZE, &scheme, &host, &port, &path));
- check_streq("http", scheme);
- check_streq("1", host);
- check_streq("/", path);
+ check_str_eq("http", scheme);
+ check_str_eq("1", host);
+ check_str_eq("/", path);
check_int_eq(80, port);
tr_free(scheme);
tr_free(path);
url = "http://www.some-tracker.org/some/path";
check(tr_urlParse(url, TR_BAD_SIZE, &scheme, &host, &port, &path));
- check_streq("http", scheme);
- check_streq("www.some-tracker.org", host);
- check_streq("/some/path", path);
+ check_str_eq("http", scheme);
+ check_str_eq("www.some-tracker.org", host);
+ check_str_eq("/some/path", path);
check_int_eq(80, port);
tr_free(scheme);
tr_free(path);
url = "http://www.some-tracker.org:80/some/path";
check(tr_urlParse(url, TR_BAD_SIZE, &scheme, &host, &port, &path));
- check_streq("http", scheme);
- check_streq("www.some-tracker.org", host);
- check_streq("/some/path", path);
+ check_str_eq("http", scheme);
+ check_str_eq("www.some-tracker.org", host);
+ check_str_eq("/some/path", path);
check_int_eq(80, port);
tr_free(scheme);
tr_free(path);
url = "http%3A%2F%2Fwww.example.com%2F~user%2F%3Ftest%3D1%26test1%3D2";
str = tr_http_unescape(url, strlen(url));
- check_streq("http://www.example.com/~user/?test=1&test1=2", str);
+ check_str_eq("http://www.example.com/~user/?test=1&test1=2", str);
tr_free(str);
return 0;
double const nan = sqrt(-1);
tr_snprintf(buf, sizeof(buf), "%.2f%%", 99.999);
- check_streq("100.00%", buf);
+ check_str_eq("100.00%", buf);
tr_snprintf(buf, sizeof(buf), "%.2f%%", tr_truncd(99.999, 2));
- check_streq("99.99%", buf);
+ check_str_eq("99.99%", buf);
tr_snprintf(buf, sizeof(buf), "%.4f", tr_truncd(403650.656250, 4));
- check_streq("403650.6562", buf);
+ check_str_eq("403650.6562", buf);
tr_snprintf(buf, sizeof(buf), "%.2f", tr_truncd(2.15, 2));
- check_streq("2.15", buf);
+ check_str_eq("2.15", buf);
tr_snprintf(buf, sizeof(buf), "%.2f", tr_truncd(2.05, 2));
- check_streq("2.05", buf);
+ check_str_eq("2.05", buf);
tr_snprintf(buf, sizeof(buf), "%.2f", tr_truncd(3.3333, 2));
- check_streq("3.33", buf);
+ check_str_eq("3.33", buf);
tr_snprintf(buf, sizeof(buf), "%.0f", tr_truncd(3.3333, 0));
- check_streq("3", buf);
+ check_str_eq("3", buf);
#if !(defined(_MSC_VER) || (defined(__MINGW32__) && defined(__MSVCRT__)))
/* FIXME: MSCVRT behaves differently in case of nan */
char* s3;
s = tr_strdup_printf("%s", "test");
- check_streq("test", s);
+ check_str_eq("test", s);
tr_free(s);
s = tr_strdup_printf("%d %s %c %u", -1, "0", '1', 2);
- check_streq("-1 0 1 2", s);
+ check_str_eq("-1 0 1 2", s);
tr_free(s);
s3 = tr_malloc0(4098);
s2[2048] = 's';
s = tr_strdup_printf(s2, "test");
- check_streq(s3, s);
+ check_str_eq(s3, s);
tr_free(s);
tr_free(s2);
s = tr_strdup_printf("%s", s3);
- check_streq(s3, s);
+ check_str_eq(s3, s);
tr_free(s);
tr_free(s3);
s = test_strdup_printf_valist("\n-%s-%s-%s-\n", "\r", "\t", "\b");
- check_streq("\n-\r-\t-\b-\n", s);
+ check_str_eq("\n-\r-\t-\b-\n", s);
tr_free(s);
return 0;
s = tr_env_get_string(test_key, NULL);
check(s == NULL);
s = tr_env_get_string(test_key, "a");
- check_streq("a", s);
+ check_str_eq("a", s);
tr_free(s);
setenv(test_key, "", 1);
x = tr_env_get_int(test_key, 456);
check_int_eq(456, x);
s = tr_env_get_string(test_key, NULL);
- check_streq("", s);
+ check_str_eq("", s);
tr_free(s);
s = tr_env_get_string(test_key, "b");
- check_streq("", s);
+ check_str_eq("", s);
tr_free(s);
setenv(test_key, "135", 1);
x = tr_env_get_int(test_key, 789);
check_int_eq(135, x);
s = tr_env_get_string(test_key, NULL);
- check_streq("135", s);
+ check_str_eq("135", s);
tr_free(s);
s = tr_env_get_string(test_key, "c");
- check_streq("135", s);
+ check_str_eq("135", s);
tr_free(s);
return 0;
#endif
check(end == str + len);
saved = tr_variantToStr(&val, TR_VARIANT_FMT_BENC, &savedLen);
- check_streq(str, saved);
+ check_str_eq(str, saved);
check_uint_eq(savedLen, len);
tr_free(saved);
tr_variantFree(&val);
check(tr_variantGetInt(&val.val.l.vals[2], &i));
check_int_eq(16, i);
saved = tr_variantToStr(&val, TR_VARIANT_FMT_BENC, &len);
- check_streq((char*)buf, saved);
+ check_str_eq((char*)buf, saved);
tr_free(saved);
tr_variantFree(&val);
check(err == 0);
check(end == buf + 2);
saved = tr_variantToStr(&val, TR_VARIANT_FMT_BENC, &len);
- check_streq("le", saved);
+ check_str_eq("le", saved);
tr_free(saved);
tr_variantFree(&val);
check((child = tr_variantListChild(&val, 0)) != NULL);
check((child2 = tr_variantListChild(child, 0)) != NULL);
saved = tr_variantToStr(&val, TR_VARIANT_FMT_BENC, &len);
- check_streq("lld1:ai64e1:bi32eeee", saved);
+ check_str_eq("lld1:ai64e1:bi32eeee", saved);
tr_free(saved);
tr_variantFree(&val);
check(err == 0);
check(end == buf + 2);
saved = tr_variantToStr(&val, TR_VARIANT_FMT_BENC, &len);
- check_streq("le", saved);
+ check_str_eq("le", saved);
tr_free(saved);
tr_variantFree(&val);
fprintf(stderr, "json: %s\n", serialized);
fprintf(stderr, "want: %s\n", expected);
#endif
- check_streq(expected, serialized);
+ check_str_eq(expected, serialized);
tr_variantFree(&top);
evbuffer_free(buf);
return 0;
check_int_eq(-35, i);
check(tr_variantDictFindStr(&dest, s5, &s, &len));
check_uint_eq(3, len);
- check_streq("abc", s);
+ check_str_eq("abc", s);
check(tr_variantDictFindStr(&dest, s6, &s, &len));
check_uint_eq(3, len);
- check_streq("xyz", s);
+ check_str_eq("xyz", s);
check(tr_variantDictFindStr(&dest, s7, &s, &len));
check_uint_eq(9, len);
- check_streq("127.0.0.1", s);
+ check_str_eq("127.0.0.1", s);
check(tr_variantDictFindStr(&dest, s8, &s, &len));
check_uint_eq(3, len);
- check_streq("ghi", s);
+ check_str_eq("ghi", s);
tr_variantFree(&dest);
tr_variantFree(&src);
check_int_eq(0, err);
check(end == in + depth * 2);
saved = tr_variantToStr(&val, TR_VARIANT_FMT_BENC, &len);
- check_streq((char*)in, saved);
+ check_str_eq((char*)in, saved);
tr_free(in);
tr_free(saved);
tr_variantFree(&val);
tr_variantDictAddStr(&top, key_str, "this-is-a-string");
benc = tr_variantToStr(&top, TR_VARIANT_FMT_BENC, &len);
- check_streq("d14:this-is-a-booli1e14:this-is-a-real8:0.50000016:this-is-a-string16:this-is-a-string14:this-is-an-int"
+ check_str_eq("d14:this-is-a-booli1e14:this-is-a-real8:0.50000016:this-is-a-string16:this-is-a-string14:this-is-an-int"
"i1234ee", benc);
check(tr_variantFromBencFull(&top2, benc, len, NULL, &end) == 0);
check(end == benc + len);
check(boolVal == true);
check(tr_variantDictFindStr(&top, key_str, &strVal, &strLen));
check_uint_eq(16, strLen);
- check_streq("this-is-a-string", strVal);
+ check_str_eq("this-is-a-string", strVal);
check(tr_variantDictFindReal(&top, key_real, &realVal));
check_int_eq(50, (int)(realVal * 100));
process_events();
check_ptr_eq(wd, wd_data.dir);
- check_streq("test", wd_data.name);
+ check_str_eq("test", wd_data.name);
tr_watchdir_free(wd);
reset_callback_data(&wd_data, TR_WATCHDIR_ACCEPT);
process_events();
check_ptr_eq(wd, wd_data.dir);
- check_streq("test", wd_data.name);
+ check_str_eq("test", wd_data.name);
reset_callback_data(&wd_data, TR_WATCHDIR_IGNORE);
create_file(test_dir, "test2");
process_events();
check_ptr_eq(wd, wd_data.dir);
- check_streq("test2", wd_data.name);
+ check_str_eq("test2", wd_data.name);
reset_callback_data(&wd_data, TR_WATCHDIR_IGNORE);
create_dir(test_dir, "test3");
process_events();
check_ptr_eq(wd1, wd1_data.dir);
- check_streq("test", wd1_data.name);
+ check_str_eq("test", wd1_data.name);
check_ptr_eq(NULL, wd2_data.dir);
check_ptr_eq(NULL, wd2_data.name);
check_ptr_eq(NULL, wd1_data.dir);
check_ptr_eq(NULL, wd1_data.name);
check_ptr_eq(wd2, wd2_data.dir);
- check_streq("test2", wd2_data.name);
+ check_str_eq("test2", wd2_data.name);
reset_callback_data(&wd1_data, TR_WATCHDIR_IGNORE);
reset_callback_data(&wd2_data, TR_WATCHDIR_IGNORE);
process_events();
check_ptr_eq(wd1, wd1_data.dir);
- check_streq("test3", wd1_data.name);
+ check_str_eq("test3", wd1_data.name);
check_ptr_eq(wd2, wd2_data.dir);
- check_streq("test4", wd2_data.name);
+ check_str_eq("test4", wd2_data.name);
reset_callback_data(&wd1_data, TR_WATCHDIR_ACCEPT);
reset_callback_data(&wd2_data, TR_WATCHDIR_ACCEPT);
process_events();
check_ptr_eq(wd1, wd1_data.dir);
- check_streq("test5", wd1_data.name);
+ check_str_eq("test5", wd1_data.name);
check_ptr_eq(NULL, wd2_data.dir);
check_ptr_eq(NULL, wd2_data.name);
check_ptr_eq(NULL, wd1_data.dir);
check_ptr_eq(NULL, wd1_data.name);
check_ptr_eq(wd2, wd2_data.dir);
- check_streq("test6", wd2_data.name);
+ check_str_eq("test6", wd2_data.name);
reset_callback_data(&wd1_data, TR_WATCHDIR_ACCEPT);
reset_callback_data(&wd2_data, TR_WATCHDIR_ACCEPT);
process_events();
check_ptr_eq(wd, wd_data.dir);
- check_streq("test", wd_data.name);
+ check_str_eq("test", wd_data.name);
tr_watchdir_free(wd);
reset_callback_data(&wd_data, TR_WATCHDIR_ACCEPT);