spa: spa_json_get_string does not return the length

The returned string is null terminated.
This commit is contained in:
Wim Taymans 2021-03-18 18:57:26 +01:00
parent 8e590df92f
commit fc9a6d6b1e
4 changed files with 15 additions and 17 deletions

View file

@ -173,13 +173,13 @@ static void test_array(char *str, char **vals)
{
struct spa_json it[2];
char val[256];
int i, len;
int i;
spa_json_init(&it[0], str, strlen(str));
if (spa_json_enter_array(&it[0], &it[1]) <= 0)
spa_json_init(&it[1], str, strlen(str));
for (i = 0; vals[i]; i++) {
spa_assert((len = spa_json_get_string(&it[1], val, sizeof(val))) > 0);
spa_assert(spa_json_get_string(&it[1], val, sizeof(val)) > 0);
spa_assert(strcmp(val, vals[i]) == 0);
}
}
@ -191,6 +191,7 @@ static void test_arrays(void)
test_array("[ FL , FR ]", (char *[]){ "FL", "FR", NULL });
test_array("[FL FR]", (char *[]){ "FL", "FR", NULL });
test_array("FL FR", (char *[]){ "FL", "FR", NULL });
test_array("[ FL FR ]", (char *[]){ "FL", "FR", NULL });
}
int main(int argc, char *argv[])