void BrokerIdTest::test2() { typedef PointerComparator< BrokerId > COMPARATOR; Pointer<BrokerId> myCommand1( new BrokerId ); Pointer<BrokerId> myCommand2( new BrokerId ); Pointer<BrokerId> myCommand3( new BrokerId ); myCommand1->setValue( "A" ); myCommand2->setValue( "A" ); myCommand3->setValue( "C" ); CPPUNIT_ASSERT( myCommand1->compareTo( *myCommand2 ) == 0 ); CPPUNIT_ASSERT( myCommand1->compareTo( *myCommand3 ) == -1 ); StlMap< Pointer<BrokerId>, int, COMPARATOR > testMap; testMap.put( myCommand3, 0 ); testMap.put( myCommand1, 0 ); CPPUNIT_ASSERT( testMap.size() == 2 ); testMap.put( myCommand2, 0 ); CPPUNIT_ASSERT( testMap.size() == 2 ); std::vector< Pointer<BrokerId> > keys = testMap.keySet().toArray(); CPPUNIT_ASSERT( keys.at( 0 )->getValue() == "A" ); CPPUNIT_ASSERT( keys.at( 1 )->getValue() == "C" ); }
void BrokerIdTest::test() { BrokerId myCommand2; BrokerId myCommand3; BrokerId myCommand1; CPPUNIT_ASSERT( myCommand1.getDataStructureType() == BrokerId::ID_BROKERID ); myCommand1.setValue( "A" ); myCommand2.setValue( "B" ); myCommand3.setValue( "C" ); StlMap< BrokerId*, int, BrokerIdComparitor > testMap; testMap.put( &myCommand1, 0 ); testMap.put( &myCommand3, 0 ); testMap.put( &myCommand2, 0 ); std::vector<BrokerId*> keys = testMap.keySet().toArray(); CPPUNIT_ASSERT( keys.at( 0 )->getValue() == "A" ); CPPUNIT_ASSERT( keys.at( 1 )->getValue() == "B" ); CPPUNIT_ASSERT( keys.at( 2 )->getValue() == "C" ); }