mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
treewide: replace strcmp() == 0 with spa_streq()
This change is only done in source files for now, header files will be done separately.
This commit is contained in:
parent
d8a9534a9a
commit
7697ed0757
130 changed files with 817 additions and 675 deletions
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include <spa/utils/defs.h>
|
||||
#include <spa/utils/json.h>
|
||||
#include <spa/utils/string.h>
|
||||
|
||||
static void test_abi(void)
|
||||
{
|
||||
|
|
@ -73,7 +74,7 @@ static void expect_string(struct spa_json *it, const char *str)
|
|||
check_type(TYPE_STRING, value, len);
|
||||
s = alloca(len+1);
|
||||
spa_json_parse_string(value, len, s);
|
||||
spa_assert(strcmp(s, str) == 0);
|
||||
spa_assert(spa_streq(s, str));
|
||||
}
|
||||
static void expect_float(struct spa_json *it, float val)
|
||||
{
|
||||
|
|
@ -156,17 +157,17 @@ static void test_encode(void)
|
|||
char dst6[6];
|
||||
char result[1024];
|
||||
spa_assert(spa_json_encode_string(dst, sizeof(dst), "test") == 6);
|
||||
spa_assert(strcmp(dst, "\"test\"") == 0);
|
||||
spa_assert(spa_streq(dst, "\"test\""));
|
||||
spa_assert(spa_json_encode_string(dst4, sizeof(dst4), "test") == 6);
|
||||
spa_assert(strncmp(dst4, "\"tes", 4) == 0);
|
||||
spa_assert(spa_json_encode_string(dst6, sizeof(dst6), "test") == 6);
|
||||
spa_assert(strncmp(dst6, "\"test\"", 6) == 0);
|
||||
spa_assert(spa_json_encode_string(dst, sizeof(dst), "test\"\n\r \t\b\f\'") == 20);
|
||||
spa_assert(strcmp(dst, "\"test\\\"\\n\\r \\t\\b\\f'\"") == 0);
|
||||
spa_assert(spa_streq(dst, "\"test\\\"\\n\\r \\t\\b\\f'\""));
|
||||
spa_assert(spa_json_encode_string(dst, sizeof(dst), "\x04\x05\x1f\x20\x01\x7f\x90") == 29);
|
||||
spa_assert(strcmp(dst, "\"\\u0004\\u0005\\u001f \\u0001\x7f\x90\"") == 0);
|
||||
spa_assert(spa_streq(dst, "\"\\u0004\\u0005\\u001f \\u0001\x7f\x90\""));
|
||||
spa_assert(spa_json_parse_string(dst, sizeof(dst), result) == 1);
|
||||
spa_assert(strcmp(result, "\x04\x05\x1f\x20\x01\x7f\x90") == 0);
|
||||
spa_assert(spa_streq(result, "\x04\x05\x1f\x20\x01\x7f\x90"));
|
||||
}
|
||||
|
||||
static void test_array(char *str, char **vals)
|
||||
|
|
@ -180,7 +181,7 @@ static void test_array(char *str, char **vals)
|
|||
spa_json_init(&it[1], str, strlen(str));
|
||||
for (i = 0; vals[i]; i++) {
|
||||
spa_assert(spa_json_get_string(&it[1], val, sizeof(val)) > 0);
|
||||
spa_assert(strcmp(val, vals[i]) == 0);
|
||||
spa_assert(spa_streq(val, vals[i]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -204,9 +205,9 @@ static void test_overflow(void)
|
|||
spa_assert(spa_json_enter_array(&it[0], &it[1]) > 0);
|
||||
|
||||
spa_assert(spa_json_get_string(&it[1], val, sizeof(val)) > 0);
|
||||
spa_assert(strcmp(val, "F") == 0);
|
||||
spa_assert(spa_streq(val, "F"));
|
||||
spa_assert(spa_json_get_string(&it[1], val, sizeof(val)) > 0);
|
||||
spa_assert(strcmp(val, "FR") == 0);
|
||||
spa_assert(spa_streq(val, "FR"));
|
||||
spa_assert(spa_json_get_string(&it[1], val, sizeof(val)) < 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue