From d8e5665e09f82ae8306789798911dc747c015eed Mon Sep 17 00:00:00 2001 From: tsntsumi Date: Thu, 19 Aug 2010 09:56:47 +0000 Subject: [PATCH] add test for setUp/tearDown calling --- tests/Makefile.am | 5 +++-- tests/failAssert.c | 34 ++++++++++++++++++++++++++++++++-- tests/runFailure.c | 4 ++-- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 16afc54..2690395 100755 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,5 +1,5 @@ ## Process this file with automake to produce Makefile.in -## Copyright (C) 2003 TSUTSUMI Kikuo. +## Copyright (C) 2003, 2010 TSUTSUMI Kikuo. ## This file is part of the CCUnit Library. ## The CCUnit Library is free software; you can redistribute it and/or @@ -31,7 +31,8 @@ runFailure_DEPENDENCIES = $(top_srcdir)/src/ccunit/libccunit.la TESTSRCS= \ testAssert.c \ testReadSuite.c \ - testSuite.c + testSuite.c \ + testSetup.c ## ls -1 fail*.c | sed -e 's/^\(.*\)$/ \1 \\/' -e '$s/ \\$//' FAILSRCS= \ diff --git a/tests/failAssert.c b/tests/failAssert.c index 69ea11a..653feb5 100644 --- a/tests/failAssert.c +++ b/tests/failAssert.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 TSUTSUMI Kikuo. +/* Copyright (C) 2003, 2010 TSUTSUMI Kikuo. This file is part of the CCUnit Library. The CCUnit Library is free software; you can redistribute it and/or @@ -77,7 +77,6 @@ static void setUp_setUp () CCUNIT_ASSERT_EQ_STR ("setUp", ""); } -/** not reached */ static void tearDown_setUp () { CCUNIT_ASSERT (false); @@ -105,3 +104,34 @@ static void test_tearUp () } /** end test case */ + +/** test case: assert in setup_setUp () */ +static void setup_setUp_test_setup_setUp () +{ + CCUNIT_ASSERT(false); +} + +/** not reached */ +static void setUp_test_setup_setUp () +{ + CCUNIT_ASSERT(false); +} + +/** not reached */ +static void tearDown_test_setup_setUp () +{ + CCUNIT_ASSERT(false); +} + +/** not reached */ +static void test_test_setup_setUp () +{ + CCUNIT_ASSERT(false); +} + +static void setup_tearDown_test_setup_setUp () +{ + CCUNIT_ASSERT(false); +} + +/** end test case */ diff --git a/tests/runFailure.c b/tests/runFailure.c index 3a80f2c..a18b2db 100644 --- a/tests/runFailure.c +++ b/tests/runFailure.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 TSUTSUMI Kikuo. +/* Copyright (C) 2003, 2010 TSUTSUMI Kikuo. This file is part of the CCUnit Library. The CCUnit Library is free software; you can redistribute it and/or @@ -53,5 +53,5 @@ int main () #if CCUNIT_WITH_DMALLOC && !CCUNIT_HAVE_ATEXIT && !CCUNIT_HAVE_ONEXIT dmalloc_shutdown (); #endif - return fails == runs + 2 ? -1 : 0; + return fails == runs + 5 ? -1 : 0; } -- 2.11.0