Ignore:
Timestamp:
Jan 6, 2011, 11:47:13 PM (15 years ago)
Author:
Frederik Heber <heber@…>
Children:
8dd38e
Parents:
567640
Message:

FIX: some unittests declared variables anew although defined in header, NULL'd in setup, deleted in tearDown().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Patterns/unittests/CreatorUnitTest.cpp

    r567640 r9f39db  
    2323
    2424#include "Assert.hpp"
    25 
    26 #include "Creator.hpp"
    27 #include "stubs/CommonStub.hpp"
    28 #include "stubs/CreatorStub.hpp"
    2925
    3026#include <boost/nondet_random.hpp>
     
    7369void CreatorTest::setUp()
    7470{
     71  testingA1 = NULL;
     72  testingA2 = NULL;
     73  testingB1 = NULL;
     74  testingB2 = NULL;
    7575}
    7676
    7777void CreatorTest::tearDown()
    7878{
     79  delete testingA1;
     80  delete testingA2;
     81  delete testingB1;
     82  delete testingB2;
    7983}
    8084
    8185void CreatorTest::CreationTest()
    8286{
    83   class CreatorStub<teststubs::Aclass> teststubA;
    84   class CreatorStub<teststubs::Bclass> teststubB;
    85 
    86   ICreatorStub* testingA1 = teststubA.create();
    87   ICreatorStub* testingA2 = teststubA.create();
    88   ICreatorStub* testingB = teststubB.create();
     87  testingA1 = teststubA.create();
     88  testingA2 = teststubA.create();
     89  testingB1 = teststubB.create();
    8990
    9091  // instance is different
     
    9293  CPPUNIT_ASSERT( &teststubA != testingA2 );
    9394  CPPUNIT_ASSERT( testingA1 != testingA2 );
    94   CPPUNIT_ASSERT( &teststubB != testingB );
     95  CPPUNIT_ASSERT( &teststubB != testingB1 );
    9596
    9697  // type is the same ...
    9798  CPPUNIT_ASSERT_EQUAL( typeid(teststubA).name(), typeid(*testingA1).name() );
    9899  CPPUNIT_ASSERT_EQUAL( typeid(*testingA1).name(), typeid(*testingA2).name() );
    99   CPPUNIT_ASSERT_EQUAL( typeid(teststubB).name(), typeid(*testingB).name() );
     100  CPPUNIT_ASSERT_EQUAL( typeid(teststubB).name(), typeid(*testingB1).name() );
    100101
    101102  // ... for the same particular type only!
    102103  // (RTTI knows about the true complex type!)
    103   CPPUNIT_ASSERT( typeid(*testingB).name() != typeid(*testingA1).name() );
    104   CPPUNIT_ASSERT( typeid(*testingB).name() != typeid(*testingA2).name() );
     104  CPPUNIT_ASSERT( typeid(*testingB1).name() != typeid(*testingA1).name() );
     105  CPPUNIT_ASSERT( typeid(*testingB1).name() != typeid(*testingA2).name() );
    105106
    106107  // but not for different encapsulated types
    107   CPPUNIT_ASSERT( typeid(teststubA).name() != typeid(*testingB).name() );
     108  CPPUNIT_ASSERT( typeid(teststubA).name() != typeid(*testingB1).name() );
    108109  CPPUNIT_ASSERT( typeid(teststubB).name() != typeid(*testingA1).name() );
    109110  CPPUNIT_ASSERT( typeid(teststubB).name() != typeid(*testingA2).name() );
    110111
    111   delete testingA1;
    112   delete testingA2;
    113   delete testingB;
    114112}
    115113
    116114void CreatorTest::IndividualityTest()
    117115{
    118   class CreatorStub<teststubs::Aclass> teststubA;
    119   class CreatorStub<teststubs::Bclass> teststubB;
    120116  teststubA.count();
    121117  teststubB.count();
    122118  teststubB.count();
    123119
    124   ICreatorStub* testingA1 = teststubA.create();
    125   ICreatorStub* testingA2 = teststubA.create();
    126   ICreatorStub* testingB1 = teststubB.create();
    127   ICreatorStub* testingB2 = teststubB.create();
     120  testingA1 = teststubA.create();
     121  testingA2 = teststubA.create();
     122  testingB1 = teststubB.create();
     123  testingB2 = teststubB.create();
    128124
    129125  // content is the same (prototype has been copied)
     
    140136  testingB2->count();
    141137  CPPUNIT_ASSERT( testingB1->getcount() != testingB2->getcount());
    142 
    143   delete testingA1;
    144   delete testingA2;
    145   delete testingB1;
    146   delete testingB2;
    147138}
Note: See TracChangeset for help on using the changeset viewer.