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