projects
/
psensor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed restoration of the panel divider position.
[psensor.git]
/
tests
/
test_psensor_type_to_unit_str.c
diff --git
a/tests/test_psensor_type_to_unit_str.c
b/tests/test_psensor_type_to_unit_str.c
index
f3eb7f4
..
6be91d5
100644
(file)
--- a/
tests/test_psensor_type_to_unit_str.c
+++ b/
tests/test_psensor_type_to_unit_str.c
@@
-28,30
+28,39
@@
#include "../src/lib/psensor.h"
#include "../src/lib/psensor.h"
-static int test_psensor_type_to_unit_str()
+static int
+test_fct(unsigned int type, int use_celsius, const char *ref)
{
const char *u;
{
const char *u;
+
+ u = psensor_type_to_unit_str(type, use_celsius);
+ if (strcmp(ref, u)) {
+ fprintf(stderr, "returns: %s expected: %s\n", u, ref);
+ return 0;
+ }
+
+ return 1;
+}
+
+static int test(void) {
int failures;
int failures;
- u = psensor_type_to_unit_str(SENSOR_TYPE_TEMP, 1);
- if (strcmp("\302\260C", u))
- failures++;
+ failures = 0;
+
+ if (!test_fct(SENSOR_TYPE_TEMP, 1, "\302\260C"))
+ failures++;
- u = psensor_type_to_unit_str(SENSOR_TYPE_TEMP, 0);
- if (strcmp("\302\260F", u))
- failures++;
+ if (!test_fct(SENSOR_TYPE_TEMP, 0, "\302\260F"))
+ failures++;
- u = psensor_type_to_unit_str(SENSOR_TYPE_LMSENSOR_TEMP, 1);
- if (strcmp("\302\260C", u))
- failures++;
+ if (!test_fct(SENSOR_TYPE_LMSENSOR | SENSOR_TYPE_TEMP, 1, "\302\260C"))
+ failures++;
- u = psensor_type_to_unit_str(SENSOR_TYPE_LMSENSOR_TEMP, 0);
- if (strcmp("\302\260F", u))
- failures++;
+ if (!test_fct(SENSOR_TYPE_LMSENSOR | SENSOR_TYPE_TEMP, 0, "\302\260F"))
+ failures++;
- u = psensor_type_to_unit_str(SENSOR_TYPE_FAN, 0);
- if (strcmp(_("RPM"), u))
- failures++;
+ if (!test_fct(SENSOR_TYPE_RPM, 0, _("RPM")))
+ failures++;
return failures;
}
return failures;
}
@@
-64,11
+73,9
@@
int main(int argc, char **argv)
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- failures = 0;
-
- failures += test_psensor_type_to_unit_str();
+ failures = test();
- if (failures)
+ if (failures)
exit(EXIT_FAILURE);
else
exit(EXIT_SUCCESS);
exit(EXIT_FAILURE);
else
exit(EXIT_SUCCESS);