Ejemplo n.º 1
0
void TestAttal::testMap()
{
    GenericMap * map = new GenericMap();
    map->newUnknownMap( 50, 60 );
    QCOMPARE( (int)map->getHeight() , 50 );
    QCOMPARE( (int)map->getWidth() , 60 );
    GenericCell * cell = NULL;

    bool except = false;
    try {
        cell = map->at( 500, 650 );
    } catch( const char * err ) {
        except = true;
    }

    QCOMPARE( except , true );

    except = false;
    try {
        cell = map->at( -5, -6 );
    } catch( const char * err ) {
        except = true;
    }

    QCOMPARE( except , true );

    except = false;
    try {
        cell = map->at( 5, 6 );
    } catch( const char * err ) {
        except = true;
    }

    QCOMPARE( except , false );
    QCOMPARE( cell->getRow() , 5 );

    map->newMapType( 50, 60,2 );
    QCOMPARE( (int)map->getHeight() , 50 );
    QCOMPARE( (int)map->getWidth() , 60 );
    QCOMPARE( (int)map->at(1,1)->getType() ,2 );

    delete map;
}
Ejemplo n.º 2
0
static bool checkGenericMapsEqual(const GenericMap & expected, const GenericMap & actual) {
	CPPUNIT_ASSERT_EQUAL(expected.size(), actual.size());
	for(auto expectedElement : expected) {
		CPPUNIT_ASSERT(actual.count(expectedElement.first) != 0);
		if(!checkGenericsEqual(expectedElement.second, actual.at(expectedElement.first))) {
			return false;
		}
	}
	return true;
}