From: Uwe Hermann Date: Sun, 6 Aug 2017 17:45:45 +0000 (+0200) Subject: sr_voltage_string(): Add a space before the unit. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=b5df922e4fbe30d04882658778d2900939e869fe;p=libsigrok.git sr_voltage_string(): Add a space before the unit. This makes the output consistent with most of the other functions in libsigrok. --- diff --git a/src/strutil.c b/src/strutil.c index 02afc034..fd9a438e 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -412,11 +412,11 @@ SR_API char *sr_period_string(uint64_t v_p, uint64_t v_q) SR_API char *sr_voltage_string(uint64_t v_p, uint64_t v_q) { if (v_q == 1000) - return g_strdup_printf("%" PRIu64 "mV", v_p); + return g_strdup_printf("%" PRIu64 " mV", v_p); else if (v_q == 1) - return g_strdup_printf("%" PRIu64 "V", v_p); + return g_strdup_printf("%" PRIu64 " V", v_p); else - return g_strdup_printf("%gV", (float)v_p / (float)v_q); + return g_strdup_printf("%g V", (float)v_p / (float)v_q); } /** diff --git a/tests/strutil.c b/tests/strutil.c index b9dbcae4..b168f1c4 100644 --- a/tests/strutil.c +++ b/tests/strutil.c @@ -227,14 +227,14 @@ END_TEST START_TEST(test_volt) { - test_voltage(34, 1, "34V"); - test_voltage(34, 2, "17V"); - test_voltage(1, 1, "1V"); - test_voltage(1, 5, "0.2V"); - test_voltage(200, 1000, "200mV"); - test_voltage(1, 72, "0.0138889V"); - test_voltage(1, 388, "0.00257732V"); - test_voltage(10, 1000, "10mV"); + test_voltage(34, 1, "34 V"); + test_voltage(34, 2, "17 V"); + test_voltage(1, 1, "1 V"); + test_voltage(1, 5, "0.2 V"); + test_voltage(200, 1000, "200 mV"); + test_voltage(1, 72, "0.0138889 V"); + test_voltage(1, 388, "0.00257732 V"); + test_voltage(10, 1000, "10 mV"); } END_TEST