[goffice] Tests: get started on a test for GOFormat.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Tests: get started on a test for GOFormat.
- Date: Wed, 2 Apr 2014 20:12:07 +0000 (UTC)
commit 7cd48bcbbeeb9ed5755007fbc00a0b5a67bed374
Author: Morten Welinder <terra gnome org>
Date: Wed Apr 2 16:11:46 2014 -0400
Tests: get started on a test for GOFormat.
ChangeLog | 2 ++
tests/Makefile.am | 6 +++++-
tests/test-format.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 56 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2fc6941..df81feb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2014-04-02 Morten Welinder <terra gnome org>
+ * tests/test-format.c: New test program.
+
* goffice/utils/go-format.c (go_format_output_conditional_to_odf):
Use go_ascii_dtoa.
(_go_number_format_init): Remove unused beyond_precision.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9433c51..56de845 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,5 +1,6 @@
+check_PROGRAMS=test-quad test-math test-format
if WITH_GTK
-check_PROGRAMS = pie-demo go-demo shapes-demo mf-demo test-quad test-math
+check_PROGRAMS += pie-demo go-demo shapes-demo mf-demo
endif
include $(top_srcdir)/goffice.mk
@@ -26,5 +27,8 @@ test_quad_SOURCES = test-quad.c
test_math_LDADD = $(GOFFICE_PLUGIN_LIBADD)
test_math_SOURCES = test-math.c
+test_format_LDADD = $(GOFFICE_PLUGIN_LIBADD)
+test_format_SOURCES = test-format.c
+
EXTRA_DIST = go-demo.ui
diff --git a/tests/test-format.c b/tests/test-format.c
new file mode 100644
index 0000000..0d34245
--- /dev/null
+++ b/tests/test-format.c
@@ -0,0 +1,49 @@
+#include <goffice/goffice.h>
+#include <string.h>
+
+/* ------------------------------------------------------------------------- */
+
+static void
+test_general_format_1 (double val, int width, const char *expected)
+{
+ GString *str = g_string_new (NULL);
+
+ go_render_general (NULL, str,
+ go_format_measure_strlen,
+ go_font_metrics_unit,
+ val, width,
+ FALSE, 0, 0);
+
+ g_printerr ("go_render_general: %.17g %d -> \"%s\"\n",
+ val, width, str->str);
+
+ g_assert (strcmp (str->str, expected) == 0);
+
+ g_string_free (str, TRUE);
+}
+
+static void
+test_general_format (void)
+{
+ test_general_format_1 (-9.5, 5, "-9.5");
+ test_general_format_1 (-9.5, 4, "-9.5");
+ test_general_format_1 (-9.5, 3, "-10");
+
+ test_general_format_1 (9.5, 5, "9.5");
+ test_general_format_1 (9.5, 3, "9.5");
+ test_general_format_1 (9.5, 2, "10");
+}
+
+/* ------------------------------------------------------------------------- */
+
+int
+main (int argc, char **argv)
+{
+ libgoffice_init ();
+
+ test_general_format ();
+
+ libgoffice_shutdown ();
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]