Skip to content

Commit

Permalink
Add unit test for tr_strjoin
Browse files Browse the repository at this point in the history
  • Loading branch information
qu1ck committed Apr 23, 2019
1 parent 0be7175 commit 5bc395e
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions libtransmission/utils-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,38 @@ static int test_strstrip(void)
return 0;
}

static int test_strjoin(void)
{
char* out;

char const* in1[] = { "one", "two" };
out = tr_strjoin(in1, 2, ", ");
check_str(out, ==, "one, two");
tr_free(out);

char const* in2[] = { "hello" };
out = tr_strjoin(in2, 1, "###");
check_str(out, ==, "hello");
tr_free(out);

char const* in3[] = { "a", "b", "ccc", "d", "eeeee" };
out = tr_strjoin(in3, 5, " ");
check_str(out, ==, "a b ccc d eeeee");
tr_free(out);

char const* in4[] = { "7", "ate", "9" };
out = tr_strjoin(in4, 3, "");
check_str(out, ==, "7ate9");
tr_free(out);

char const** in5;
out = tr_strjoin(in5, 0, "a");
check_str(out, ==, "");
tr_free(out);

return 0;
}

static int test_buildpath(void)
{
char* out;
Expand Down Expand Up @@ -540,6 +572,7 @@ int main(void)
test_strip_positional_args,
test_strdup_printf,
test_strstrip,
test_strjoin,
test_truncd,
test_url,
test_utf8,
Expand Down

0 comments on commit 5bc395e

Please sign in to comment.