Skip to content

Commit b5df922

Browse files
committed
sr_voltage_string(): Add a space before the unit.
This makes the output consistent with most of the other functions in libsigrok.
1 parent c911599 commit b5df922

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/strutil.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,11 +412,11 @@ SR_API char *sr_period_string(uint64_t v_p, uint64_t v_q)
412412
SR_API char *sr_voltage_string(uint64_t v_p, uint64_t v_q)
413413
{
414414
if (v_q == 1000)
415-
return g_strdup_printf("%" PRIu64 "mV", v_p);
415+
return g_strdup_printf("%" PRIu64 " mV", v_p);
416416
else if (v_q == 1)
417-
return g_strdup_printf("%" PRIu64 "V", v_p);
417+
return g_strdup_printf("%" PRIu64 " V", v_p);
418418
else
419-
return g_strdup_printf("%gV", (float)v_p / (float)v_q);
419+
return g_strdup_printf("%g V", (float)v_p / (float)v_q);
420420
}
421421

422422
/**

tests/strutil.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,14 @@ END_TEST
227227

228228
START_TEST(test_volt)
229229
{
230-
test_voltage(34, 1, "34V");
231-
test_voltage(34, 2, "17V");
232-
test_voltage(1, 1, "1V");
233-
test_voltage(1, 5, "0.2V");
234-
test_voltage(200, 1000, "200mV");
235-
test_voltage(1, 72, "0.0138889V");
236-
test_voltage(1, 388, "0.00257732V");
237-
test_voltage(10, 1000, "10mV");
230+
test_voltage(34, 1, "34 V");
231+
test_voltage(34, 2, "17 V");
232+
test_voltage(1, 1, "1 V");
233+
test_voltage(1, 5, "0.2 V");
234+
test_voltage(200, 1000, "200 mV");
235+
test_voltage(1, 72, "0.0138889 V");
236+
test_voltage(1, 388, "0.00257732 V");
237+
test_voltage(10, 1000, "10 mV");
238238
}
239239
END_TEST
240240

0 commit comments

Comments
 (0)