OSDN Git Service

setUp/tearDown call test
[ccunit/ccunit.git] / tests / testSetup.c
1 /* Copyright (C) 2010 TSUTSUMI Kikuo.
2    This file is part of the CCUnit Library.
3
4    The CCUnit Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public License
6    as published by the Free Software Foundation; either version 2.1 of
7    the License, or (at your option) any later version.
8
9    The CCUnit Library is distributed in the hope that it will be
10    useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11    of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU Lesser General Public License for more details.
13
14    You should have received a copy of the GNU Lesser General Public
15    License along with the CCUnit Library; see the file COPYING.LESSER.
16    If not, see <http://www.gnu.org/licenses/>
17 */
18
19 /*
20  * $Id$
21  */
22 #include <stdio.h>
23 #include <ccunit/CCUnitAssert.h>
24
25 /** test case: test setup */
26
27 static int setUpCount;
28 static int tearDownCount;
29
30 void setup_setUp_testSetup ()
31 {
32   setUpCount = 0;
33   tearDownCount = 0;
34 }
35
36 void setup_tearDown_testSetup ()
37 {
38   CCUNIT_ASSERT_EQ_INT(setUpCount, 3);
39   CCUNIT_ASSERT_EQ_INT(tearDownCount, 3);
40 }
41
42 void setUp_testSetup ()
43 {
44   setUpCount ++;
45 }
46
47 void tearDown_testSetup ()
48 {
49   tearDownCount ++;
50 }
51
52 void test_testSetup1 ()
53 {
54   CCUNIT_ASSERT_EQ_INT(setUpCount, 1);
55   CCUNIT_ASSERT_EQ_INT(tearDownCount, 0);
56 }
57
58 void test_testSetup2 ()
59 {
60   CCUNIT_ASSERT_EQ_INT(setUpCount, 2);
61   CCUNIT_ASSERT_EQ_INT(tearDownCount, 1);
62 }
63
64 void test_testSetup3 ()
65 {
66   CCUNIT_ASSERT_EQ_INT(setUpCount, 3);
67   CCUNIT_ASSERT_EQ_INT(tearDownCount, 2);
68 }
69
70 /** end test case */