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:
parent
c911599da7
commit
b5df922e4f
|
@ -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)
|
SR_API char *sr_voltage_string(uint64_t v_p, uint64_t v_q)
|
||||||
{
|
{
|
||||||
if (v_q == 1000)
|
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)
|
else if (v_q == 1)
|
||||||
return g_strdup_printf("%" PRIu64 "V", v_p);
|
return g_strdup_printf("%" PRIu64 " V", v_p);
|
||||||
else
|
else
|
||||||
return g_strdup_printf("%gV", (float)v_p / (float)v_q);
|
return g_strdup_printf("%g V", (float)v_p / (float)v_q);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -227,14 +227,14 @@ END_TEST
|
||||||
|
|
||||||
START_TEST(test_volt)
|
START_TEST(test_volt)
|
||||||
{
|
{
|
||||||
test_voltage(34, 1, "34V");
|
test_voltage(34, 1, "34 V");
|
||||||
test_voltage(34, 2, "17V");
|
test_voltage(34, 2, "17 V");
|
||||||
test_voltage(1, 1, "1V");
|
test_voltage(1, 1, "1 V");
|
||||||
test_voltage(1, 5, "0.2V");
|
test_voltage(1, 5, "0.2 V");
|
||||||
test_voltage(200, 1000, "200mV");
|
test_voltage(200, 1000, "200 mV");
|
||||||
test_voltage(1, 72, "0.0138889V");
|
test_voltage(1, 72, "0.0138889 V");
|
||||||
test_voltage(1, 388, "0.00257732V");
|
test_voltage(1, 388, "0.00257732 V");
|
||||||
test_voltage(10, 1000, "10mV");
|
test_voltage(10, 1000, "10 mV");
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue