3 * Copyright (C) 2009 Julien Peeters
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 * Julien Peeters <contact@julienpeeters.fr>
23 public abstract class Gee.TestCase : Object {
25 private GLib.TestSuite suite;
26 private Adaptor[] adaptors = new Adaptor[0];
28 public delegate void TestMethod ();
30 public TestCase (string name) {
31 this.suite = new GLib.TestSuite (name);
34 public void add_test (string name, owned TestMethod test) {
35 var adaptor = new Adaptor (name, (owned)test, this);
36 this.adaptors += adaptor;
38 this.suite.add (new GLib.TestCase (adaptor.name,
44 public virtual void set_up () {
47 public virtual void tear_down () {
50 public GLib.TestSuite get_suite () {
54 private class Adaptor {
55 [CCode (notify = false)]
56 public string name { get; private set; }
57 private TestMethod test;
58 private TestCase test_case;
60 public Adaptor (string name,
61 owned TestMethod test,
64 this.test = (owned)test;
65 this.test_case = test_case;
68 public void set_up (void* fixture) {
69 this.test_case.set_up ();
72 public void run (void* fixture) {
76 public void tear_down (void* fixture) {
77 this.test_case.tear_down ();