diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2024-04-02 19:32:13 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2024-04-07 13:18:13 +0200 |
commit | 2cf66de4236ca05024917c183c24f4dede4aa6d9 (patch) | |
tree | 204d66805a8e955a7ba8f2319d551db4e7c0b9c3 /tests/unit/core/test-core-string.cpp | |
parent | 08bc6404eb0d7d6fb276c33d9f4cd6499c63d624 (diff) | |
download | weechat-2cf66de4236ca05024917c183c24f4dede4aa6d9.zip |
api: add function "asprintf"
Diffstat (limited to 'tests/unit/core/test-core-string.cpp')
-rw-r--r-- | tests/unit/core/test-core-string.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/unit/core/test-core-string.cpp b/tests/unit/core/test-core-string.cpp index 8881d2df5..2d6552a31 100644 --- a/tests/unit/core/test-core-string.cpp +++ b/tests/unit/core/test-core-string.cpp @@ -125,6 +125,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 */ |