void GenericBitVectorTests::testSelect() {

    auto pair = makeTestData();
    GenericBitVector* v = pair.first;
    BitVectorIterator* v2 = new BitVectorIterator(*pair.second);
    
    for(size_t i = 0; i < 3; i++) {
        // Check a bunch of positions.
        CPPUNIT_ASSERT(v->select(i) == v2->select(i));
    }
    
    delete pair.first;
    delete pair.second;
    delete v2;

}
Ejemplo n.º 2
0
int main(int argc, char *argv[]) {
	printf("%s %d",argv[0],argc);
	dataStore *test = calloc(1,sizeof(dataStore));
	highscoreTestdata(test);
	SDL_Surface* screen=initSDL();
	readDataStore(test);
	menuStart(screen, test);
	saveDataStore(test);
	/* just for testing*/
	makeTestData(test);
	//createRandomField(test);
	updateGraphics(screen,test);
	graphicLoop(screen,test);
//	gameloop(test,screen);
	quitSDL();
//	free(test);
	return 0;
}
void GenericBitVectorTests::testRank() {

    auto pair = makeTestData();
    GenericBitVector* v = pair.first;
    BitVectorIterator* v2 = new BitVectorIterator(*pair.second);
    
    for(size_t i = 0; i < 20; i++) {
        // Check a bunch of positions.
        Log::info() << "Position " << i << " ranks: " << v->rank(i) << 
            " vs. " << v2->rank(i) << std::endl;
        CPPUNIT_ASSERT(v->rank(i) == v2->rank(i));
        CPPUNIT_ASSERT(v->rank(i, true) == v2->rank(i, true));
        CPPUNIT_ASSERT(v->rank(i, false) == v2->rank(i, false));
    }
    
    delete pair.first;
    delete pair.second;
    delete v2;

}
void GenericBitVectorTests::testValueBefore() {
    
    auto pair = makeTestData();
    GenericBitVector* v = pair.first;
    BitVectorIterator* v2 = new BitVectorIterator(*pair.second);
    
    for(size_t i = 0; i < 10; i++) {
        // Check a bunch of positions.
        auto ourResult = v->valueBefore(i);
        auto theirResult = v2->valueBefore(i);
        Log::info() << "Position " << i << ": " << ourResult.first << ", " <<
            ourResult.second << " vs. " << theirResult.first << ", " << 
            theirResult.second << std::endl;
        CPPUNIT_ASSERT(ourResult == theirResult);
    }
    
    delete pair.first;
    delete pair.second;
    delete v2;
}