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:
Wim Taymans 2025-07-07 12:09:55 +02:00
parent 5f4b4b02f9
commit deb7dddbef

View file

@ -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 */