예제 #1
0
void Project2Test::test_MGFramework_resetupMO()
{
	// Setup
	MGFrameworkStub mgf;
	mgf.init(16, 16, 32, 32);
	mgf._addMO(1);
	ASSERT_EQ(mgf._getNumberOfMO(), 1, "MGF failed to create MO");
	ASSERT_EQ(mgf._m_MO().size() == 0, false, "MGF failed to create MO");

	mgf._setupMO(mgf.nthMO(0), 4, 5, 2, 3, 0, 0, 0, 0);
	ASSERT_EQ(mgf.nthMO(0)->getTileX(), 4, "MGF failed to setup MO x");
	ASSERT_EQ(mgf.nthMO(0)->getTileY(), 5, "MGF failed to setup MO y");
	ASSERT_EQ(mgf.nthMO(0)->getOwner(), 2, "MGF failed to setup MO owner");

	// Trigger
	mgf._setupMO(mgf.nthMO(0), 8, 9, 10, 3, 0, 0, 0, 0);
	ASSERT_EQ(mgf.nthMO(0)->getTileX(), 8, "MGF failed to setup MO x");
	ASSERT_EQ(mgf.nthMO(0)->getTileY(), 9, "MGF failed to setup MO y");
	ASSERT_EQ(mgf.nthMO(0)->getOwner(), 10, "MGF failed to setup MO owner");

	mgf._deleteMO(mgf.nthMO(0));
	mgf._addMO(1);
	mgf._setupMO(mgf.nthMO(0), 4, 5, 2, 3, 0, 0, 0, 0);

	// Verify
	ASSERT_EQ(mgf.nthMO(0)->getTileX(), 4, "MGF failed to setup MO x");
	ASSERT_EQ(mgf.nthMO(0)->getTileY(), 5, "MGF failed to setup MO y");
	ASSERT_EQ(mgf.nthMO(0)->getOwner(), 2, "MGF failed to setup MO owner");
}
예제 #2
0
void Project2Test::test_MGFramework_createMO()
{
	// Setup
	MGFrameworkStub mgf;
	ASSERT_EQ(mgf._getNumberOfMO(), 0, "MGF created with MO");

	EXPECT_ERROR("MGFramework::addMO cannot create 1 MO on a 0 by 0 map");
	mgf._addMO(1);
	ASSERT_EQ(mgf._getNumberOfMO(), 0, "MGF created MOs without initializing the map");
	mgf.init(16, 16, 32, 32);

	// Trigger/Verify
	mgf._addMO(0);
	ASSERT_EQ(mgf._getNumberOfMO(), 0, "MGF failed to create zero MO");
	mgf._addMO(1);
	ASSERT_EQ(mgf._getNumberOfMO(), 1, "MGF failed to create MO");
	mgf._addMO(3);
	ASSERT_EQ(mgf._getNumberOfMO(), 4, "MGF failed to create MO");
	mgf._addMO(1);
	ASSERT_EQ(mgf._getNumberOfMO(), 5, "MGF failed to create MO");
	mgf._addMO(15);
	ASSERT_EQ(mgf._getNumberOfMO(), 20, "MGF failed to create MO");
	mgf._addMO(0);
	ASSERT_EQ(mgf._getNumberOfMO(), 20, "MGF failed to create zero MO");
}
예제 #3
0
void Project2Test::test_MGFramework_deleteFirstMO()
{
	// Setup
	MGFrameworkStub mgf;
	ASSERT_EQ(mgf._getNumberOfMO(), 0, "MGF created with MO");
	mgf.init(16, 16, 32, 32);
	mgf._addMO(2);
	ASSERT_EQ(mgf._getNumberOfMO(), 2, "MGF failed to create MO");

	std::list<MGMovingObject>::iterator it = mgf.nthMO(0);
	mgf.nthMO(0)->setOwner(0);
	mgf.nthMO(1)->setOwner(1);

	// Trigger - delete first MO
	mgf._deleteMO(it);

	// Verify
	ASSERT_EQ(mgf._getNumberOfMO(), 1, "MGF failed to delete MO");
	ASSERT_EQ(mgf.nthMO(0)->getOwner(), 1, "MGF did not delete the right MO");

	// Setup - create another 3 MO
	it = mgf.nthMO(0);
	mgf._addMO(3);
	mgf.nthMO(0)->setOwner(0);
	mgf.nthMO(1)->setOwner(1);
	mgf.nthMO(2)->setOwner(2);
	mgf.nthMO(3)->setOwner(3);

	// Trigger - delete first MO again
	mgf._deleteMO(it);

	// Verify
	ASSERT_EQ(mgf._getNumberOfMO(), 3, "MGF failed to delete MO");
	ASSERT_EQ(mgf.nthMO(0)->getOwner(), 1, "MGF did not delete the right MO");
	ASSERT_EQ(mgf.nthMO(1)->getOwner(), 2, "MGF did not delete the right MO");
	ASSERT_EQ(mgf.nthMO(2)->getOwner(), 3, "MGF did not delete the right MO");
}
예제 #4
0
void Project2Test::test_MGFramework_deleteAllMO()
{
	// Setup
	MGFrameworkStub mgf;
	ASSERT_EQ(mgf._getNumberOfMO(), 0, "MGF created with MO");
	mgf.init(16, 16, 32, 32);
	mgf._addMO(15);
	ASSERT_EQ(mgf._getNumberOfMO(), 15, "MGF failed to create MO");

	// Trigger
	mgf.runConsoleCommand("delete all mo", &mgf, NULL);

	// Verify
	ASSERT_EQ(mgf._getNumberOfMO(), 0, "MGF failed to delete all MO");

	// Delete all MO when no MO exist
	mgf.runConsoleCommand("delete all mo", &mgf, NULL);
	ASSERT_EQ(mgf._getNumberOfMO(), 0, "MGF failed to delete all MO on empty MO list");
}
예제 #5
0
void Project2Test::test_MGFramework_deleteMO()
{
	// Setup
	MGFrameworkStub mgf;
	ASSERT_EQ(mgf._getNumberOfMO(), 0, "MGF created with MO");
	mgf.init(16, 16, 32, 32);
	mgf._addMO(15);
	ASSERT_EQ(mgf._getNumberOfMO(), 15, "MGF failed to create MO");

	// Trigger/Verify

	// Delete first MO
	mgf._deleteMO(mgf.nthMO(0));
	ASSERT_EQ(mgf._getNumberOfMO(), 14, "MGF failed to delete MO");
	mgf._deleteMO(mgf.nthMO(0));
	ASSERT_EQ(mgf._getNumberOfMO(), 13, "MGF failed to delete MO");
	mgf._deleteMO(mgf.nthMO(0));
	ASSERT_EQ(mgf._getNumberOfMO(), 12, "MGF failed to delete MO");

	// Delete last MO
	mgf._deleteMO(mgf.nthMO(11));
	ASSERT_EQ(mgf._getNumberOfMO(), 11, "MGF failed to delete MO");

	// Delete arbitrary MO
	mgf._deleteMO(mgf.nthMO(7));
	ASSERT_EQ(mgf._getNumberOfMO(), 10, "MGF failed to delete MO");

	// Delete MO outside container
	mgf._deleteMO(mgf.nthMO(17));
	ASSERT_EQ(mgf._getNumberOfMO(), 10, "MGF failed to delete zero MO");

	// Delete all MO
	mgf._deleteAllMO();
	ASSERT_EQ(mgf._getNumberOfMO(), 0, "MGF failed to delete MO");

	// Delete all MO when no MO exist
	mgf._deleteAllMO();
	ASSERT_EQ(mgf._getNumberOfMO(), 0, "MGF failed to run deleteAllMO");
}