[libgee] Some more enhancements to the test infrastructure
- From: Didier 'Ptitjes' Villevalois <dvillevalois src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libgee] Some more enhancements to the test infrastructure
- Date: Sun, 6 Sep 2009 16:43:38 +0000 (UTC)
commit 87d1b15a8ed40de1ee056d905ebbd605e4649859
Author: Julien Peeters <contact julienpeeters fr>
Date: Sat Sep 5 16:25:54 2009 +0200
Some more enhancements to the test infrastructure
TestCase is a more appropriate name, and so are set_up and tear_down.
tests/Makefile.am | 4 +-
tests/testarraylist.vala | 5 +--
tests/{testfixture.vala => testcase.vala} | 55 ++++++++++++++---------------
tests/testcollection.vala | 3 +-
4 files changed, 32 insertions(+), 35 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e7a82e0..f0c3c52 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -12,8 +12,8 @@ noinst_PROGRAMS = $(TEST_PROGS)
progs_ldadd = $(GLIB_LIBS) ../gee/libgee.la
TEST_PROGS += testarraylist
-testarraylist_VALASOURCES = testarraylist.vala testcollection.vala testfixture.vala
-testarraylist_SOURCES = testarraylist.c testcollection.c testfixture.c
+testarraylist_VALASOURCES = testarraylist.vala testcollection.vala testcase.vala
+testarraylist_SOURCES = testarraylist.c testcollection.c testcase.c
$(testarraylist_SOURCES): $(testarraylist_VALASOURCES)
$(VALAC) -C --basedir $(top_srcdir) --vapidir $(top_srcdir)/gee --pkg gee-1.0 $^
touch $@
diff --git a/tests/testarraylist.vala b/tests/testarraylist.vala
index 0c79dba..1e90a0d 100644
--- a/tests/testarraylist.vala
+++ b/tests/testarraylist.vala
@@ -20,7 +20,6 @@
* Jürg Billeter <j bitron ch>
*/
-using GLib;
using Gee;
public class ArrayListTests : CollectionTests {
@@ -54,13 +53,13 @@ public class ArrayListTests : CollectionTests {
add_test("iterator", test_arraylist_iterator);
}
- public override void setup () {
+ public override void set_up () {
int_collection = new ArrayList<int> ();
string_collection = new ArrayList<string> (str_equal);
object_collection = new ArrayList<Object> ();
}
- public override void teardown () {
+ public override void tear_down () {
int_collection = null;
string_collection = null;
object_collection = null;
diff --git a/tests/testfixture.vala b/tests/testcase.vala
similarity index 54%
rename from tests/testfixture.vala
rename to tests/testcase.vala
index 861a3b6..1d77a6d 100644
--- a/tests/testfixture.vala
+++ b/tests/testcase.vala
@@ -20,63 +20,62 @@
* Julien Peeters <contact julienpeeters fr>
*/
-using GLib;
+public abstract class Gee.TestCase : GLib.Object {
-public abstract class TestFixture: Object {
-
- private TestSuite suite;
- private TestAdaptor[] adaptors = new TestAdaptor[0];
+ private GLib.TestSuite suite;
+ private Adaptor[] adaptors = new Adaptor[0];
public delegate void TestMethod ();
- public TestFixture (string name) {
- this.suite = new TestSuite (name);
+ public TestCase (string name) {
+ this.suite = new GLib.TestSuite (name);
}
public void add_test (string name, TestMethod test) {
- var adaptor = new TestAdaptor (name, test, this);
+ var adaptor = new Adaptor (name, test, this);
this.adaptors += adaptor;
- this.suite.add (new TestCase (adaptor.name,
- 0,
- adaptor.setup,
- adaptor.run,
- adaptor.teardown ));
+ this.suite.add (new GLib.TestCase (adaptor.name,
+ 0,
+ adaptor.set_up,
+ adaptor.run,
+ adaptor.tear_down ));
}
- public virtual void setup () {}
- public virtual void teardown () {}
+ public virtual void set_up () {
+ }
- public TestSuite get_suite () {
- return this.suite;
+ public virtual void tear_down () {
}
- public void add_to_suite (TestSuite suite) {
- suite.add_suite (this.suite);
+ public GLib.TestSuite get_suite () {
+ return this.suite;
}
- private class TestAdaptor {
+ private class Adaptor {
- public string name { set; get; }
+ public string name { get; private set; }
private TestMethod test;
- private TestFixture fixture;
+ private TestCase test_case;
- public TestAdaptor (string name, TestMethod test, TestFixture fixture) {
+ public Adaptor (string name,
+ TestMethod test,
+ TestCase test_case) {
this.name = name;
this.test = test;
- this.fixture = fixture;
+ this.test_case = test_case;
}
- public void setup (void* fixture) {
- this.fixture.setup ();
+ public void set_up (void* fixture) {
+ this.test_case.set_up ();
}
public void run (void* fixture) {
this.test ();
}
- public void teardown (void* fixture) {
- this.fixture.teardown ();
+ public void tear_down (void* fixture) {
+ this.test_case.tear_down ();
}
}
}
diff --git a/tests/testcollection.vala b/tests/testcollection.vala
index 4c31cd8..406448a 100644
--- a/tests/testcollection.vala
+++ b/tests/testcollection.vala
@@ -21,10 +21,9 @@
* Didier 'Ptitjes' Villevalois <ptitjes free fr>
*/
-using GLib;
using Gee;
-public abstract class CollectionTests : TestFixture {
+public abstract class CollectionTests : Gee.TestCase {
public CollectionTests (string name) {
base(name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]