mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
test: format float values with .
Depending on the locale, the decimal separator can be , or . We need it to be . in all cases or else the checks for the expected value might fail.
This commit is contained in:
parent
5f4b4b02f9
commit
deb7dddbef
1 changed files with 9 additions and 2 deletions
|
|
@ -882,8 +882,15 @@ static int validate_strict_json(struct spa_json *it, int depth, FILE *f)
|
||||||
fprintf(f, "%d", v);
|
fprintf(f, "%d", v);
|
||||||
} else if (spa_json_is_float(value, len)) {
|
} else if (spa_json_is_float(value, len)) {
|
||||||
float v;
|
float v;
|
||||||
if (spa_json_parse_float(value, len, &v) > 0)
|
char float_str[64];
|
||||||
fprintf(f, "%G", v);
|
if (spa_json_parse_float(value, len, &v) > 0) {
|
||||||
|
int i, l;
|
||||||
|
l = spa_scnprintf(float_str, sizeof(float_str), "%G", v);
|
||||||
|
for (i = 0; i < l; i++)
|
||||||
|
if (float_str[i] == ',')
|
||||||
|
float_str[i] = '.';
|
||||||
|
fprintf(f, "%s", float_str);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* bare value: error here, as we want to test
|
/* bare value: error here, as we want to test
|
||||||
* int/float/etc parsing */
|
* int/float/etc parsing */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue