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 StlMapTest::testSize() { StlMap<string, bool> boolMap; CPPUNIT_ASSERT(boolMap.size() == 0 ); boolMap.put( "bob", true ); CPPUNIT_ASSERT(boolMap.size() == 1 ); boolMap.put( "fred", true ); CPPUNIT_ASSERT(boolMap.size() == 2 ); }
void StlMapTest::testIsEmpty() { StlMap<string, bool> boolMap; boolMap.put( "bob", true ); boolMap.put( "fred", true ); CPPUNIT_ASSERT(boolMap.isEmpty() == false ); boolMap.clear(); CPPUNIT_ASSERT(boolMap.isEmpty() == true ); }
void StlMapTest::testContiansValue() { StlMap<string, bool> boolMap; boolMap.put( "fred", true ); boolMap.put( "fred1", false ); CPPUNIT_ASSERT( boolMap.containsValue(true) == true ); boolMap.remove( "fred" ); CPPUNIT_ASSERT( boolMap.containsValue(true) == false ); }
void StlMapTest::testPut() { StlMap<string, bool> boolMap; boolMap.put( "fred", true ); CPPUNIT_ASSERT( boolMap.get("fred") == true ); boolMap.put( "bob", false ); CPPUNIT_ASSERT( boolMap.get("bob") == false ); CPPUNIT_ASSERT( boolMap.get("fred") == true ); boolMap.put( "bob", true ); CPPUNIT_ASSERT( boolMap.get("bob") == true ); CPPUNIT_ASSERT( boolMap.get("fred") == true ); }
void StlMapTest::testGet() { StlMap<string, bool> boolMap; boolMap.put( "fred", true ); CPPUNIT_ASSERT( boolMap.get("fred") == true ); boolMap.put( "bob", false ); CPPUNIT_ASSERT( boolMap.get("bob") == false ); CPPUNIT_ASSERT( boolMap.get("fred") == true ); try{ boolMap.get( "mike" ); CPPUNIT_ASSERT(false); } catch( decaf::lang::exceptions::NoSuchElementException& e ){ } }
void StlMapTest::testContainsKey(){ StlMap<string, bool> boolMap; CPPUNIT_ASSERT(boolMap.containsKey("bob") == false); boolMap.put( "bob", true ); CPPUNIT_ASSERT(boolMap.containsKey("bob") == true ); CPPUNIT_ASSERT(boolMap.containsKey("fred") == false ); }
void StlMapTest::testRemove() { StlMap<string, bool> boolMap; boolMap.put( "fred", true ); CPPUNIT_ASSERT( boolMap.containsKey("fred") == true ); CPPUNIT_ASSERT( boolMap.remove( "fred" ) == true ); CPPUNIT_ASSERT( boolMap.containsKey("fred") == false ); CPPUNIT_ASSERT_THROW_MESSAGE( "Should throw a NoSuchElementException", boolMap.remove( "fred" ), decaf::lang::exceptions::NoSuchElementException ); }
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" ); }