Ignore:
Timestamp:
Jan 4, 2011, 5:15:14 PM (15 years ago)
Author:
Frederik Heber <heber@…>
Children:
1afcbe
Parents:
746ff1
git-author:
Frederik Heber <heber@…> (01/04/11 15:57:33)
git-committer:
Frederik Heber <heber@…> (01/04/11 17:15:14)
Message:

Factory know has an additional type table and stubs have been refactored.

  • CommonStub.?pp contains basic classes with a int counter inside.
  • Library version is now 2:1:0, API is 1.0.3.
File:
1 edited

Legend:

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

    r746ff1 r724564  
    2222#include "FactoryUnitTest.hpp"
    2323
     24#include "stubs/CommonStub.hpp"
    2425#include "stubs/FactoryStub.hpp"
    2526
     
    6869void FactoryTest::setUp()
    6970{
    70   FactoryStub::getInstance();
     71  rndA =
     72      FactoryStub::getInstance().
     73      PrototypeTable[FactoryStub::Aclass]->create();
     74  rndB =
     75      FactoryStub::getInstance().
     76      PrototypeTable[FactoryStub::Bclass]->create();
    7177}
    7278
    7379void FactoryTest::tearDown()
    7480{
     81  delete rndA;
     82  delete rndB;
    7583  FactoryStub::purgeInstance();
    7684}
     
    93101  }
    94102
    95   // check one of the distributions in the table
    96   ICreatorStub * rnd =
    97       FactoryStub::getInstance().
    98       PrototypeTable[FactoryStub::Aclass]->create();
     103  // check distributions in the table
    99104  CPPUNIT_ASSERT_EQUAL(
    100105      std::string(typeid(teststubs::Aclass).name()),
    101       rnd->name()
     106      rndA->name()
    102107  );
    103   delete rnd;
     108  CPPUNIT_ASSERT_EQUAL(
     109      std::string(typeid(teststubs::Bclass).name()),
     110      rndB->name()
     111  );
    104112}
     113
     114
     115void FactoryTest::getProductEnumTest()
     116{
     117  ICreatorStub * rndA_1 =
     118      FactoryStub::getInstance().getProduct(FactoryStub::Aclass);
     119  CPPUNIT_ASSERT( typeid(*rndA) == typeid(*rndA_1) );
     120  delete rndA_1;
     121}
     122
     123void FactoryTest::getProductNameTest()
     124{
     125  ICreatorStub * rndA_1 =
     126      FactoryStub::getInstance().getProduct(std::string("Aclass"));
     127  CPPUNIT_ASSERT( typeid(*rndA) == typeid(*rndA_1) );
     128  delete rndA_1;
     129}
     130
     131void FactoryTest::getProductTypeTest()
     132{
     133  ICreatorStub * rndA_1 =
     134      FactoryStub::getInstance().getProduct( typeid(teststubs::Aclass) );
     135  CPPUNIT_ASSERT( typeid(*rndA) == typeid(*rndA_1) );
     136  delete rndA_1;
     137}
Note: See TracChangeset for help on using the changeset viewer.