| 1 | /*
|
|---|
| 2 | * Project: MoleCuilder
|
|---|
| 3 | * Description: creates and alters molecular systems
|
|---|
| 4 | * Copyright (C) 2016 Frederik Heber. All rights reserved.
|
|---|
| 5 | *
|
|---|
| 6 | *
|
|---|
| 7 | * This file is part of MoleCuilder.
|
|---|
| 8 | *
|
|---|
| 9 | * MoleCuilder is free software: you can redistribute it and/or modify
|
|---|
| 10 | * it under the terms of the GNU General Public License as published by
|
|---|
| 11 | * the Free Software Foundation, either version 2 of the License, or
|
|---|
| 12 | * (at your option) any later version.
|
|---|
| 13 | *
|
|---|
| 14 | * MoleCuilder is distributed in the hope that it will be useful,
|
|---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 17 | * GNU General Public License for more details.
|
|---|
| 18 | *
|
|---|
| 19 | * You should have received a copy of the GNU General Public License
|
|---|
| 20 | * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 21 | */
|
|---|
| 22 |
|
|---|
| 23 | /*
|
|---|
| 24 | * SubgraphEdgeUnitTest.cpp
|
|---|
| 25 | *
|
|---|
| 26 | * Created on: Oct 03, 2016
|
|---|
| 27 | * Author: heber
|
|---|
| 28 | */
|
|---|
| 29 |
|
|---|
| 30 | // include config.h
|
|---|
| 31 | #ifdef HAVE_CONFIG_H
|
|---|
| 32 | #include <config.h>
|
|---|
| 33 | #endif
|
|---|
| 34 |
|
|---|
| 35 | using namespace std;
|
|---|
| 36 |
|
|---|
| 37 | #include <cppunit/CompilerOutputter.h>
|
|---|
| 38 | #include <cppunit/extensions/TestFactoryRegistry.h>
|
|---|
| 39 | #include <cppunit/ui/text/TestRunner.h>
|
|---|
| 40 |
|
|---|
| 41 | #include "../../../FunctionApproximation/Subgraph/unittests/SubgraphEdgeUnitTest.hpp"
|
|---|
| 42 |
|
|---|
| 43 | #include <boost/assign.hpp>
|
|---|
| 44 |
|
|---|
| 45 | #include "CodePatterns/Assert.hpp"
|
|---|
| 46 |
|
|---|
| 47 | #include "../../../FunctionApproximation/Subgraph/SubgraphEdge.hpp"
|
|---|
| 48 |
|
|---|
| 49 | using namespace boost::assign;
|
|---|
| 50 |
|
|---|
| 51 | #ifdef HAVE_TESTRUNNER
|
|---|
| 52 | #include "UnitTestMain.hpp"
|
|---|
| 53 | #endif /*HAVE_TESTRUNNER*/
|
|---|
| 54 |
|
|---|
| 55 | /********************************************** Test classes **************************************/
|
|---|
| 56 |
|
|---|
| 57 | // Registers the fixture into the 'registry'
|
|---|
| 58 | CPPUNIT_TEST_SUITE_REGISTRATION( SubgraphEdgeTest );
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 | void SubgraphEdgeTest::setUp()
|
|---|
| 62 | {
|
|---|
| 63 | // failing asserts should be thrown
|
|---|
| 64 | ASSERT_DO(Assert::Throw);
|
|---|
| 65 |
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 | void SubgraphEdgeTest::tearDown()
|
|---|
| 70 | {
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | /** UnitTest for TypeComparator()
|
|---|
| 74 | */
|
|---|
| 75 | void SubgraphEdgeTest::TypeComparatorTest()
|
|---|
| 76 | {
|
|---|
| 77 | SubgraphEdge arg( std::make_pair(1,2), std::make_pair(1,1) );
|
|---|
| 78 | SubgraphEdge otherarg( std::make_pair(1,2), std::make_pair(2,1) );
|
|---|
| 79 | SubgraphEdge anotherarg( std::make_pair(1,2), std::make_pair(1,2) );
|
|---|
| 80 |
|
|---|
| 81 | CPPUNIT_ASSERT( SubgraphEdge::TypeComparator(arg, otherarg) );
|
|---|
| 82 | CPPUNIT_ASSERT( !SubgraphEdge::TypeComparator(arg, anotherarg) );
|
|---|
| 83 | CPPUNIT_ASSERT( !SubgraphEdge::TypeComparator(otherarg, anotherarg) );
|
|---|
| 84 | }
|
|---|
| 85 |
|
|---|
| 86 | /** UnitTest for operator<()
|
|---|
| 87 | */
|
|---|
| 88 | void SubgraphEdgeTest::ComparatorTest()
|
|---|
| 89 | {
|
|---|
| 90 | SubgraphEdge zeroarg( std::make_pair(0,2), std::make_pair(3,1) );
|
|---|
| 91 | SubgraphEdge firstarg( std::make_pair(1,2), std::make_pair(1,1) );
|
|---|
| 92 | SubgraphEdge firstarg_latertype( std::make_pair(1,2), std::make_pair(2,1) );
|
|---|
| 93 | SubgraphEdge secondarg( std::make_pair(2,3), std::make_pair(1,2) );
|
|---|
| 94 |
|
|---|
| 95 | CPPUNIT_ASSERT( zeroarg < firstarg );
|
|---|
| 96 | CPPUNIT_ASSERT( zeroarg < firstarg_latertype );
|
|---|
| 97 | CPPUNIT_ASSERT( firstarg < firstarg_latertype );
|
|---|
| 98 | CPPUNIT_ASSERT( zeroarg < secondarg );
|
|---|
| 99 | CPPUNIT_ASSERT( firstarg < secondarg );
|
|---|
| 100 | CPPUNIT_ASSERT( firstarg_latertype < secondarg );
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | /** UnitTest for operator==()
|
|---|
| 104 | */
|
|---|
| 105 | void SubgraphEdgeTest::EqualityTest()
|
|---|
| 106 | {
|
|---|
| 107 | SubgraphEdge arg( std::make_pair(1,2), std::make_pair(1,1) );
|
|---|
| 108 | SubgraphEdge arg_different_type( std::make_pair(1,2), std::make_pair(1,2) );
|
|---|
| 109 | SubgraphEdge arg_different_index( std::make_pair(0,2), std::make_pair(1,1) );
|
|---|
| 110 | SubgraphEdge samearg( std::make_pair(1,2), std::make_pair(1,2) );
|
|---|
| 111 |
|
|---|
| 112 | CPPUNIT_ASSERT( !(arg == arg_different_type) );
|
|---|
| 113 | CPPUNIT_ASSERT( !(arg == arg_different_index) );
|
|---|
| 114 | CPPUNIT_ASSERT( arg == samearg );
|
|---|
| 115 | }
|
|---|