示例#1
0
static void testEmployeeHandling (void)
{
	employeeType_t type;

	ResetCampaignData();

	for (type = 0; type < MAX_EMPL; type++) {
		if (type != EMPL_ROBOT) {
			int cnt;
			employee_t *e = E_CreateEmployee(type, NULL, NULL);
			CU_ASSERT_PTR_NOT_NULL(e);

			cnt = E_CountUnhired(type);
			CU_ASSERT_EQUAL(cnt, 1);

			E_DeleteEmployee(e);

			cnt = E_CountUnhired(type);
			CU_ASSERT_EQUAL(cnt, 0);
		}
	}

	{
		int i;
		const int amount = 3;
		for (i = 0; i < amount; i++) {
			employee_t *e = E_CreateEmployee(EMPL_SOLDIER, NULL, NULL);
			CU_ASSERT_PTR_NOT_NULL(e);
		}
		{
			employee_t *e;
			int cnt = 0;
			E_Foreach(EMPL_SOLDIER, e) {
				cnt++;
			}

			CU_ASSERT_EQUAL(cnt, amount);

			E_Foreach(EMPL_SOLDIER, e) {
				CU_ASSERT_TRUE(E_DeleteEmployee(e));
			}

			cnt = E_CountUnhired(EMPL_SOLDIER);
			CU_ASSERT_EQUAL(cnt, 0)
		}
	}
示例#2
0
TEST_F(CampaignTest, testEmployeeHandling)
{
	int i;

	for (i = 0; i < MAX_EMPL; i++) {
		employeeType_t type = (employeeType_t)i;
		if (type != EMPL_ROBOT) {
			int cnt;
			Employee* e = E_CreateEmployee(type, nullptr, nullptr);
			ASSERT_TRUE(nullptr != e);

			cnt = E_CountUnhired(type);
			ASSERT_EQ(cnt, 1);

			E_DeleteEmployee(e);

			cnt = E_CountUnhired(type);
			ASSERT_EQ(cnt, 0);
		}
	}

	{
		const int amount = 3;
		for (i = 0; i < amount; i++) {
			Employee* e = E_CreateEmployee(EMPL_SOLDIER, nullptr, nullptr);
			ASSERT_TRUE(nullptr != e);
		}
		{
			int cnt = 0;
			E_Foreach(EMPL_SOLDIER, e) {
				(void)e;
				cnt++;
			}

			ASSERT_EQ(cnt, amount);

			E_Foreach(EMPL_SOLDIER, e) {
				ASSERT_TRUE(E_DeleteEmployee(e));
			}

			cnt = E_CountUnhired(EMPL_SOLDIER);
			ASSERT_EQ(cnt, 0);
		}