[gtksourceview] Reenable test-region test



commit 050dac4b482a42f65e4e9dfee9d2e68bf154c4b0
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Jan 13 21:59:50 2013 +0100

    Reenable test-region test
    
    We can use the priv lib to reenable the textregion test and turn it into
    a unit test

 tests/Makefile.am                     |   15 +++++++--------
 tests/{testregion.c => test-region.c} |   26 ++++++++++++++++++--------
 2 files changed, 25 insertions(+), 16 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d91a735..62d904d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -73,18 +73,17 @@ test_completion_model_LDADD =					\
 	$(DEP_LIBS)						\
 	$(TESTS_LIBS)
 
+UNIT_TEST_PROGS += test-region
+test_region_SOURCES = test-region.c
+test_region_LDADD = 						\
+	$(top_builddir)/gtksourceview/libgtksourceview-private.la	\
+	$(DEP_LIBS)			\
+	$(TESTS_LIBS)
+
 python_tests =			\
 	test-completion.py	\
 	test-widget.py
 
-# testregion need gtk_text_region_ api which is normally private
-# modify gtksourceview/Makefile.am to export gtk_text_* symbols
-# TEST_PROGS += testregion
-#testregion_SOURCES = testregion.c
-#testregion_LDADD = 			\
-#	$(top_builddir)/gtksourceview/libgtksourceview-3.0.la \
-#	$(DEP_LIBS)
-
 EXTRA_DIST =				\
 	language-specs/test-empty.lang	\
 	language-specs/test-full.lang	\
diff --git a/tests/testregion.c b/tests/test-region.c
similarity index 92%
rename from tests/testregion.c
rename to tests/test-region.c
index c6a460c..f3622a7 100644
--- a/tests/testregion.c
+++ b/tests/test-region.c
@@ -1,9 +1,8 @@
 #include <gtk/gtk.h>
 #include "gtksourceview/gtktextregion.h"
 
-
-int
-main (int argc, char **argv)
+static void
+test_region (void)
 {
 	GtkTextBuffer *buffer;
 	GtkTextRegion *region, *intersection;
@@ -68,8 +67,6 @@ main (int argc, char **argv)
 		{  3,  7 }
 	};
 
-	gtk_init (&argc, &argv);
-
 	buffer = gtk_text_buffer_new (NULL);
 	region = gtk_text_region_new (buffer);
 
@@ -79,7 +76,7 @@ main (int argc, char **argv)
 	gtk_text_region_get_iterator (region, &reg_iter, 0);
 	if (!gtk_text_region_iterator_is_end (&reg_iter)) {
 		g_print ("problem fetching iterator for an empty region\n");
-		return -1;
+		g_assert_not_reached ();
 	}
 
 	for (i = 0; i < NUM_OPS; i++) {
@@ -127,20 +124,33 @@ main (int argc, char **argv)
 
 		if (!gtk_text_iter_equal (&s, &s1) ||
 		    !gtk_text_iter_equal (&e, &e1))
+		{
 			g_print ("problem iterating\n");
+			g_assert_not_reached ();
+		}
 
 		++i;
 		gtk_text_region_iterator_next (&reg_iter);
 	}
 
 	if (i != gtk_text_region_subregions (region))
+	{
 		g_print ("problem iterating all subregions\n");
+		g_assert_not_reached ();
+	}
 
 	g_print ("iterated %d subregions\n", i);
 
 	gtk_text_region_destroy (region, TRUE);
 	g_object_unref (buffer);
-
-	return 0;
 }
 
+int
+main (int argc, char** argv)
+{
+	gtk_test_init (&argc, &argv);
+
+	g_test_add_func ("/Region/region", test_region);
+
+	return g_test_run();
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]