/******************************************************************************* * ALMA - Atacama Large Millimiter Array * (c) European Southern Observatory, 2002 * Copyright by ESO (in the framework of the ALMA collaboration) * and Cosylab 2002, All rights reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "vltPort.h" #include /* * A test case that is designed to produce * example errors and failures * */ class ExampleTestCase : public CPPUNIT_NS::TestFixture { CPPUNIT_TEST_SUITE( ExampleTestCase ); CPPUNIT_TEST( example ); CPPUNIT_TEST( anotherExample ); CPPUNIT_TEST( testAdd ); CPPUNIT_TEST( testEquals ); CPPUNIT_TEST_SUITE_END(); protected: double m_value1; double m_value2; public: void setUp(); protected: void example(); void anotherExample(); void testAdd(); void testDivideByZero(); void testEquals(); }; CPPUNIT_TEST_SUITE_REGISTRATION( ExampleTestCase ); void ExampleTestCase::example() { CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, 1.1, 0.2 ); CPPUNIT_ASSERT( 1 == 1 ); } void ExampleTestCase::anotherExample() { CPPUNIT_ASSERT (2 == 2); } void ExampleTestCase::setUp() { m_value1 = 2.0; m_value2 = 3.0; } void ExampleTestCase::testAdd() { double result = m_value1 + m_value2; CPPUNIT_ASSERT( result == 5.0 ); } void ExampleTestCase::testEquals() { long* l1 = new long(12); long* l2 = new long(12); CPPUNIT_ASSERT_EQUAL( 12, 12 ); CPPUNIT_ASSERT_EQUAL( 12L, 12L ); CPPUNIT_ASSERT_EQUAL( *l1, *l2 ); delete l1; delete l2; CPPUNIT_ASSERT( 12L == 12L ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 12.0, 11.99, 0.5 ); } /* * Main function running the tests */ #include #include #include #include int main( int argc, char* argv[] ) { CppUnit::TextTestRunner runner; runner.addTest( ExampleTestCase::suite() ); runner.run("",false,true,false); }