sr_voltage_string(): Add a space before the unit.

This makes the output consistent with most of the other functions
in libsigrok.
This commit is contained in:
Uwe Hermann 2017-08-06 19:45:45 +02:00
parent c911599da7
commit b5df922e4f
2 changed files with 11 additions and 11 deletions

View File

@ -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);
}
/**

View File

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