Skip to content

Commit

Permalink
sr_voltage_string(): Add a space before the unit.
Browse files Browse the repository at this point in the history
This makes the output consistent with most of the other functions
in libsigrok.
  • Loading branch information
uwehermann committed Aug 6, 2017
1 parent c911599 commit b5df922
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/strutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
16 changes: 8 additions & 8 deletions tests/strutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit b5df922

Please sign in to comment.