[gnome-scan] Added common tests
- From: Étienne Bersac <bersace src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-scan] Added common tests
- Date: Sat, 13 Mar 2010 20:34:02 +0000 (UTC)
commit 3b3d4e01aabc2932cf685680259060780dc469dd
Author: Ã?tienne Bersac <bersace gnome org>
Date: Sat Mar 13 21:32:14 2010 +0100
Added common tests
lib/gnome-scan-common.vala | 6 ++-
lib/gnome-scan-init.vala | 5 ++
lib/tests/Makefile.am | 6 ++-
lib/tests/common.c | 141 ++++++++++++++++++++++++++++++++++++++++++++
lib/tests/module.c | 3 +-
lib/tests/options.c | 3 +-
6 files changed, 159 insertions(+), 5 deletions(-)
---
diff --git a/lib/gnome-scan-common.vala b/lib/gnome-scan-common.vala
index cf3fd7e..efaa578 100644
--- a/lib/gnome-scan-common.vala
+++ b/lib/gnome-scan-common.vala
@@ -44,6 +44,9 @@ namespace Gnome.Scan {
return _("pt");
case Unit.MM:
return _("mm");
+ case Unit.INCH:
+ /* translators: Shortname for Inch unit */
+ return _("in");
case Unit.BIT:
return _("bit");
case Unit.DPI:
@@ -96,6 +99,7 @@ namespace Gnome.Scan {
public double max;
}
+ /* do we actually need a GObject here ??? */
public class Format : GLib.Object {
public weak string name;
public weak string desc;
@@ -130,7 +134,7 @@ namespace Gnome.Scan {
private const double MM_PER_INCH = 25.4;
- // debugging facility, return the nickk of value.
+ // debugging facility, return the nick of value.
public string enum_get_nick(GLib.Type enum_type,
int value)
{
diff --git a/lib/gnome-scan-init.vala b/lib/gnome-scan-init.vala
index 35a7cbd..c2b09ad 100644
--- a/lib/gnome-scan-init.vala
+++ b/lib/gnome-scan-init.vala
@@ -28,6 +28,11 @@ namespace Gnome.Scan {
// should be private !
public ModuleManager module_manager;
+ public void init_test([CCode (array_length_pos = 0.9)]ref string[] argv)
+ {
+ Gegl.init(ref argv);
+ }
+
public void init([CCode (array_length_pos = 0.9)]ref weak string[] argv)
{
debug("Initializing GNOME Scan %s for %s", Config.VERSION, GLib.Environment.get_prgname());
diff --git a/lib/tests/Makefile.am b/lib/tests/Makefile.am
index e382580..2c5d857 100644
--- a/lib/tests/Makefile.am
+++ b/lib/tests/Makefile.am
@@ -11,10 +11,14 @@ AM_CFLAGS = -Wall -g
noinst_PROGRAMS = $(TEST_PROGS)
+TEST_PROGS += common
+common_SOURCES = common.c
+common_LDADD = $(LIBS)
+
TEST_PROGS += options
options_SOURCES = options.c
options_LDADD = $(LIBS)
TEST_PROGS += module
module_SOURCES = module.c
-module_LDADD = $(LIBS)
+module_LDADD = $(LIBS)
\ No newline at end of file
diff --git a/lib/tests/common.c b/lib/tests/common.c
new file mode 100644
index 0000000..25a4c69
--- /dev/null
+++ b/lib/tests/common.c
@@ -0,0 +1,141 @@
+/* GNOME Scan - Scan as easy as you print
+ * Copyright © 2006-2008 �tienne Bersac <bersace gnome org>
+ *
+ * GNOME Scan is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * GNOME Scan 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GNOME Scan. If not, write to:
+ *
+ * the Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301, USA
+ */
+
+#include <gnome-scan.h>
+
+static void
+unit_pixel ()
+{
+ GnomeScanUnit unit = GNOME_SCAN_UNIT_PIXEL;
+ const gchar* string;
+
+ string = gnome_scan_unit_to_string(unit);
+
+ g_assert_cmpstr(string, ==, "px");
+}
+
+static void
+unit_point ()
+{
+ GnomeScanUnit unit = GNOME_SCAN_UNIT_POINTS;
+ const gchar* string;
+
+ string = gnome_scan_unit_to_string(unit);
+
+ g_assert_cmpstr(string, ==, "pt");
+}
+
+static void
+unit_millimeter ()
+{
+ GnomeScanUnit unit = GNOME_SCAN_UNIT_MM;
+ const gchar* string;
+
+ string = gnome_scan_unit_to_string(unit);
+
+ g_assert_cmpstr(string, ==, "mm");
+}
+
+static void
+unit_bit ()
+{
+ GnomeScanUnit unit = GNOME_SCAN_UNIT_BIT;
+ const gchar* string;
+
+ string = gnome_scan_unit_to_string(unit);
+
+ g_assert_cmpstr(string, ==, "bit");
+}
+
+static void
+unit_dpi ()
+{
+ GnomeScanUnit unit = GNOME_SCAN_UNIT_DPI;
+ const gchar* string;
+
+ string = gnome_scan_unit_to_string(unit);
+
+ g_assert_cmpstr(string, ==, "dpi");
+}
+
+static void
+unit_percent ()
+{
+ GnomeScanUnit unit = GNOME_SCAN_UNIT_PERCENT;
+ const gchar* string;
+
+ string = gnome_scan_unit_to_string(unit);
+
+ g_assert_cmpstr(string, ==, "%");
+}
+
+static void
+unit_inch ()
+{
+ GnomeScanUnit unit = GNOME_SCAN_UNIT_INCH;
+ const gchar* string;
+
+ string = gnome_scan_unit_to_string(unit);
+
+ g_assert_cmpstr(string, ==, "in");
+}
+
+static void
+unit_microsecond ()
+{
+ GnomeScanUnit unit = GNOME_SCAN_UNIT_MICROSECOND;
+ const gchar* string;
+
+ string = gnome_scan_unit_to_string(unit);
+
+ g_assert_cmpstr(string, ==, "µs");
+}
+
+static void
+enum_value_nick ()
+{
+ gchar *nick;
+
+ nick = gnome_scan_enum_get_nick (GNOME_SCAN_TYPE_UNIT, GNOME_SCAN_UNIT_MM);
+
+ g_assert_cmpstr (nick, ==, "mm");
+}
+
+gint
+main(gint argc, gchar**argv)
+{
+ g_set_prgname("module");
+ g_type_init();
+ g_test_init(&argc, &argv, NULL);
+ gnome_scan_init_test(&argc, &argv);
+
+ g_test_add_func("/common/unit/pixel", unit_pixel);
+ g_test_add_func("/common/unit/point", unit_point);
+ g_test_add_func("/common/unit/millimeter", unit_millimeter);
+ g_test_add_func("/common/unit/bit", unit_bit);
+ g_test_add_func("/common/unit/dpi", unit_dpi);
+ g_test_add_func("/common/unit/percent", unit_percent);
+ g_test_add_func("/common/unit/inch", unit_inch);
+ g_test_add_func("/common/unit/microsecond", unit_microsecond);
+ g_test_add_func("/common/enum_value_nick", enum_value_nick);
+
+ return g_test_run();
+}
diff --git a/lib/tests/module.c b/lib/tests/module.c
index 221223b..990327d 100644
--- a/lib/tests/module.c
+++ b/lib/tests/module.c
@@ -19,7 +19,6 @@
* Boston, MA 02110-1301, USA
*/
-#include <glib.h>
#include <gnome-scan.h>
static void
@@ -87,7 +86,7 @@ main(gint argc, gchar**argv)
g_set_prgname("module");
g_type_init();
g_test_init(&argc, &argv, NULL);
- gnome_scan_init(&argc, &argv);
+ gnome_scan_init_test(&argc, &argv);
g_test_add_func("/module/name/extract", name_extract);
g_test_add_func("/module/name/validate/so", name_validate_so);
g_test_add_func("/module/name/validate/la", name_validate_la);
diff --git a/lib/tests/options.c b/lib/tests/options.c
index 7a5461e..b315f00 100644
--- a/lib/tests/options.c
+++ b/lib/tests/options.c
@@ -19,11 +19,12 @@
* Boston, MA 02110-1301, USA
*/
-#include <glib-object.h>
+#include <gnome-scan.h>
gint main(gint argc, gchar**argv)
{
g_set_prgname("options");
+ gnome_scan_init_test(&argc, &argv);
g_type_init();
g_test_init(&argc, &argv, NULL);
return g_test_run();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]