added trace to debug the failing test in LP
[psensor.git] / tests / test_psensor_type_to_unit_str.c
1 /*
2  * Copyright (C) 2010-2011 jeanfi@gmail.com
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301 USA
18  */
19
20 #include <stdlib.h>
21 #include <stdio.h>
22 #include <string.h>
23 #include <sys/stat.h>
24
25 #include <locale.h>
26 #include <libintl.h>
27 #define _(str) gettext(str)
28
29 #include "../src/lib/psensor.h"
30
31 static int test_psensor_type_to_unit_str()
32 {
33         const char *u;
34         int failures;
35
36         u = psensor_type_to_unit_str(SENSOR_TYPE_TEMP, 1);
37         if (strcmp("\302\260C", u))
38                 failures++;
39
40         u = psensor_type_to_unit_str(SENSOR_TYPE_TEMP, 0);
41         if (strcmp("\302\260F", u))
42                 failures++;
43
44         u = psensor_type_to_unit_str(SENSOR_TYPE_LMSENSOR_TEMP, 1);
45         if (strcmp("\302\260C", u))
46                 failures++;
47
48         u = psensor_type_to_unit_str(SENSOR_TYPE_LMSENSOR_TEMP, 0);
49         if (strcmp("\302\260F", u))
50                 failures++;
51         
52         u = psensor_type_to_unit_str(SENSOR_TYPE_FAN, 0);
53         fprintf(stdout, "returns: %s expected: %s\n", u, _("RPM"));
54         if (strcmp(_("RPM"), u)) {
55                 failures++;
56         }
57
58         return failures;
59 }
60
61 int main(int argc, char **argv)
62 {
63         int failures;
64
65         setlocale(LC_ALL, "");
66         bindtextdomain(PACKAGE, LOCALEDIR);
67         textdomain(PACKAGE);
68
69         failures = 0;
70
71         failures += test_psensor_type_to_unit_str();
72
73         if (failures) 
74                 exit(EXIT_FAILURE);
75         else
76                 exit(EXIT_SUCCESS);
77 }