1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-25 04:16:38 +02:00

api: add function "asprintf"

This commit is contained in:
Sébastien Helleu
2024-04-02 19:32:13 +02:00
parent 08bc6404eb
commit 2cf66de423
10 changed files with 360 additions and 2 deletions
+37
View File
@@ -123,6 +123,43 @@ TEST_GROUP(CoreString)
{
};
/*
* Tests functions:
* string_asprintf
*/
TEST(CoreString, Asprintf)
{
char *test;
test = (char *)0x1;
LONGS_EQUAL(-1, string_asprintf (NULL, NULL));
POINTERS_EQUAL(0x1, test);
test = (char *)0x1;
LONGS_EQUAL(-1, string_asprintf (NULL, ""));
POINTERS_EQUAL(0x1, test);
test = (char *)0x1;
LONGS_EQUAL(-1, string_asprintf (&test, NULL));
POINTERS_EQUAL(NULL, test);
test = (char *)0x1;
LONGS_EQUAL(0, string_asprintf (&test, ""));
STRCMP_EQUAL("", test);
free (test);
test = (char *)0x1;
LONGS_EQUAL(4, string_asprintf (&test, "test"));
STRCMP_EQUAL("test", test);
free (test);
test = (char *)0x1;
LONGS_EQUAL(16, string_asprintf (&test, "test, %s, %d", "string", 42));
STRCMP_EQUAL("test, string, 42", test);
free (test);
}
/*
* Tests functions:
* string_strndup