From deb7dddbef77965cff58a958c194e226425e451a Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 7 Jul 2025 12:09:55 +0200 Subject: [PATCH] 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. --- test/test-spa-json.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/test-spa-json.c b/test/test-spa-json.c index b07acc00d..66ef2eeac 100644 --- a/test/test-spa-json.c +++ b/test/test-spa-json.c @@ -882,8 +882,15 @@ static int validate_strict_json(struct spa_json *it, int depth, FILE *f) fprintf(f, "%d", v); } else if (spa_json_is_float(value, len)) { float v; - if (spa_json_parse_float(value, len, &v) > 0) - fprintf(f, "%G", v); + char float_str[64]; + 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 { /* bare value: error here, as we want to test * int/float/etc parsing */