source: src/Helpers/unittests/AssertUnitTest.cpp@ d2023c

Last change on this file since d2023c was 0fce81, checked in by Frederik Heber <heber@…>, 15 years ago

Moved unittests to Helpers/unittests, split off TestRunner into new unittests.

  • Unit tests should reside in a subdir of where the components to test reside in.
  • everything common to all unit tests resides in a specific unittests subdir of the src folder.
  • for now, SUBDIRS directive for Helpers/unittests and Patterns/unittests resides in ./ and not in src/Makefile.am to assure that libCodePatterns is compiled before. We need to re-structure the unit tests to not relie in the lib itself anymore but just on components and stubs.
  • Property mode set to 100644
File size: 1.5 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/*
9 * AssertUnitTest.cpp
10 *
11 * Created on: Feb 10, 2011
12 * Author: heber
13 */
14
15
16// include config.h
17#ifdef HAVE_CONFIG_H
18#include <config.h>
19#endif
20
21using namespace std;
22
23#include <cppunit/CompilerOutputter.h>
24#include <cppunit/extensions/TestFactoryRegistry.h>
25#include <cppunit/ui/text/TestRunner.h>
26
27#include "Assert.hpp"
28
29#include "AssertUnitTest.hpp"
30
31#ifdef HAVE_TESTRUNNER
32#include "UnitTestMain.hpp"
33#endif /*HAVE_TESTRUNNER*/
34
35/********************************************** Test classes **************************************/
36
37// Registers the fixture into the 'registry'
38CPPUNIT_TEST_SUITE_REGISTRATION( AssertTest );
39
40void testfunction() {
41 ASSERT(0==1, "testfunction() - 0 != 1");
42}
43
44void testfunction2() {
45 ASSERT(0==0, "testfunction() - 0 != 0");
46}
47
48void AssertTest::setUp()
49{
50 ASSERT_DO(Assert::Ignore);
51};
52
53void AssertTest::tearDown()
54{};
55
56/**
57 * UnitTest for execeptions thrown by ASSERT()
58 */
59void AssertTest::ThrowTest()
60{
61 // test throw
62 ASSERT_DO(Assert::Throw);
63 CPPUNIT_ASSERT_THROW(testfunction(), Assert::AssertionFailure);
64 CPPUNIT_ASSERT_NO_THROW(testfunction2());
65 // test no throws on ignore (abort and others would interrupt unit test)
66 ASSERT_DO(Assert::Ignore);
67 CPPUNIT_ASSERT_NO_THROW(testfunction());
68};
Note: See TracBrowser for help on using the repository browser.