check_PROGRAMS = test-io-dir-list \
test-psensor-type-to-unit-str \
+ test-psensor-value-to-str \
test-url-encode \
test-url-normalize
LIBS += $(GTOP_LIBS)
endif
+test_io_dir_list_SOURCES = test_io_dir_list.c
test_psensor_type_to_unit_str_SOURCES = test_psensor_type_to_unit_str.c
-
+test_psensor_value_to_str_SOURCES = test_psensor_value_to_str.c
test_url_encode_SOURCES = test_url_encode.c
-
test_url_normalize_SOURCES = test_url_normalize.c
-test_io_dir_list_SOURCES = test_io_dir_list.c
-
-TESTS = test-psensor-type-to-unit-str \
+TESTS = test-io-dir-list.sh \
+ test-psensor-type-to-unit-str \
+ test-psensor-value-to-str \
test-url-encode \
- test-url-normalize \
- test-io-dir-list.sh
\ No newline at end of file
+ test-url-normalize
host_triplet = @host@
check_PROGRAMS = test-io-dir-list$(EXEEXT) \
test-psensor-type-to-unit-str$(EXEEXT) \
- test-url-encode$(EXEEXT) test-url-normalize$(EXEEXT)
+ test-psensor-value-to-str$(EXEEXT) test-url-encode$(EXEEXT) \
+ test-url-normalize$(EXEEXT)
@ATASMART_TRUE@am__append_1 = $(ATASMART_LIBS)
@GTOP_TRUE@am__append_2 = $(GTOP_LIBS)
-TESTS = test-psensor-type-to-unit-str$(EXEEXT) \
- test-url-encode$(EXEEXT) test-url-normalize$(EXEEXT) \
- test-io-dir-list.sh
+TESTS = test-io-dir-list.sh test-psensor-type-to-unit-str$(EXEEXT) \
+ test-psensor-value-to-str$(EXEEXT) test-url-encode$(EXEEXT) \
+ test-url-normalize$(EXEEXT)
subdir = tests
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
test_psensor_type_to_unit_str_OBJECTS = \
$(am_test_psensor_type_to_unit_str_OBJECTS)
test_psensor_type_to_unit_str_LDADD = $(LDADD)
+am_test_psensor_value_to_str_OBJECTS = \
+ test_psensor_value_to_str.$(OBJEXT)
+test_psensor_value_to_str_OBJECTS = \
+ $(am_test_psensor_value_to_str_OBJECTS)
+test_psensor_value_to_str_LDADD = $(LDADD)
am_test_url_encode_OBJECTS = test_url_encode.$(OBJEXT)
test_url_encode_OBJECTS = $(am_test_url_encode_OBJECTS)
test_url_encode_LDADD = $(LDADD)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(test_io_dir_list_SOURCES) \
$(test_psensor_type_to_unit_str_SOURCES) \
+ $(test_psensor_value_to_str_SOURCES) \
$(test_url_encode_SOURCES) $(test_url_normalize_SOURCES)
DIST_SOURCES = $(test_io_dir_list_SOURCES) \
$(test_psensor_type_to_unit_str_SOURCES) \
+ $(test_psensor_value_to_str_SOURCES) \
$(test_url_encode_SOURCES) $(test_url_normalize_SOURCES)
ETAGS = etags
CTAGS = ctags
top_srcdir = @top_srcdir@
EXTRA_DIST = checkpatch.pl data test-io-dir-list.sh
AM_CPPFLAGS = -pedantic -Werror
+test_io_dir_list_SOURCES = test_io_dir_list.c
test_psensor_type_to_unit_str_SOURCES = test_psensor_type_to_unit_str.c
+test_psensor_value_to_str_SOURCES = test_psensor_value_to_str.c
test_url_encode_SOURCES = test_url_encode.c
test_url_normalize_SOURCES = test_url_normalize.c
-test_io_dir_list_SOURCES = test_io_dir_list.c
all: all-am
.SUFFIXES:
test-psensor-type-to-unit-str$(EXEEXT): $(test_psensor_type_to_unit_str_OBJECTS) $(test_psensor_type_to_unit_str_DEPENDENCIES) $(EXTRA_test_psensor_type_to_unit_str_DEPENDENCIES)
@rm -f test-psensor-type-to-unit-str$(EXEEXT)
$(LINK) $(test_psensor_type_to_unit_str_OBJECTS) $(test_psensor_type_to_unit_str_LDADD) $(LIBS)
+test-psensor-value-to-str$(EXEEXT): $(test_psensor_value_to_str_OBJECTS) $(test_psensor_value_to_str_DEPENDENCIES) $(EXTRA_test_psensor_value_to_str_DEPENDENCIES)
+ @rm -f test-psensor-value-to-str$(EXEEXT)
+ $(LINK) $(test_psensor_value_to_str_OBJECTS) $(test_psensor_value_to_str_LDADD) $(LIBS)
test-url-encode$(EXEEXT): $(test_url_encode_OBJECTS) $(test_url_encode_DEPENDENCIES) $(EXTRA_test_url_encode_DEPENDENCIES)
@rm -f test-url-encode$(EXEEXT)
$(LINK) $(test_url_encode_OBJECTS) $(test_url_encode_LDADD) $(LIBS)
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_io_dir_list.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_psensor_type_to_unit_str.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_psensor_value_to_str.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_url_encode.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_url_normalize.Po@am__quote@
--- /dev/null
+/*
+ * Copyright (C) 2010-2011 jeanfi@gmail.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+
+#include "../src/lib/psensor.h"
+
+#define CELCIUS "\302\260C"
+#define FAHRENHEIT "\302\260F"
+
+static int
+test_psensor_value_to_str(unsigned int type,
+ double value,
+ int celcius,
+ const char *ref)
+{
+ char *str;
+
+ str = psensor_value_to_str(type, value, celcius);
+ if (strcmp(ref, str))
+ return 1;
+ else
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ int errs;
+
+ errs = test_psensor_value_to_str(SENSOR_TYPE_TEMP, 13, 1,
+ "13"CELCIUS);
+ errs += test_psensor_value_to_str(SENSOR_TYPE_TEMP, 13, 0,
+ "13"FAHRENHEIT);
+ errs += test_psensor_value_to_str(SENSOR_TYPE_TEMP, 13.4, 1,
+ "13"CELCIUS);
+ errs += test_psensor_value_to_str(SENSOR_TYPE_TEMP, 13.5, 0,
+ "14"FAHRENHEIT);
+
+ if (errs)
+ exit(EXIT_FAILURE);
+ else
+ exit(EXIT_SUCCESS);
+}