228 lines
4.5 KiB
C++
228 lines
4.5 KiB
C++
#include "pch.h"
|
|
|
|
#pragma once
|
|
#include <BWAPI.h>
|
|
|
|
#include "../Source/BWEM/src/bwem.h"
|
|
#include "../Source/Macro.h"
|
|
|
|
using namespace BWAPI;
|
|
|
|
|
|
namespace MacroTest
|
|
{
|
|
namespace { auto& map = BWEM::Map::Instance(); }
|
|
|
|
int selfID = 1;
|
|
|
|
TilePosition tp1 = TilePosition(1, 1);
|
|
|
|
TEST(MacroTest, DISABLED_addBase)
|
|
{
|
|
EXPECT_EQ(int(Macro::bases.size()), 0);
|
|
Macro::addBase(tp1);
|
|
EXPECT_EQ(int(Macro::bases.size()), 1);
|
|
}
|
|
|
|
TEST(MacroTest, addLocation)
|
|
{
|
|
EXPECT_EQ(int(Macro::locations.size()), 0);
|
|
Macro::addLocation(tp1, false);
|
|
EXPECT_EQ(int(Macro::locations.size()), 1);
|
|
}
|
|
|
|
TEST(MacroTest, addPlayer)
|
|
{
|
|
BWAPI::Player p = BWAPI::Player();
|
|
|
|
EXPECT_EQ(int(Macro::players.size()), 0);
|
|
Macro::addPlayer(p);
|
|
EXPECT_EQ(int(Macro::players.size()), 1);
|
|
}
|
|
|
|
TEST(MacroTest, addSquad)
|
|
{
|
|
EXPECT_EQ(int(Macro::squads.size()), 0);
|
|
Macro::addSquad();
|
|
EXPECT_EQ(int(Macro::squads.size()), 1);
|
|
}
|
|
|
|
TEST(MacroTest, DISABLED_analyzeQueue)
|
|
{
|
|
EXPECT_EQ(1, 0);
|
|
}
|
|
|
|
TEST(MacroTest, DISABLED_assignBase)
|
|
{
|
|
BWAPI::Player p = BWAPI::Player();
|
|
|
|
CBase c = CBase();
|
|
Macro::addPlayer(p);
|
|
|
|
Macro::assignBase(p->getID(), c);
|
|
|
|
EXPECT_EQ(int(Macro::players.front().bases.size()), 1);
|
|
}
|
|
|
|
TEST(MacroTest, DISABLED_findMiningBase)
|
|
{
|
|
EXPECT_EQ(1, 0);
|
|
}
|
|
|
|
TEST(MacroTest, DISABLED_freeUnit)
|
|
{
|
|
EXPECT_EQ(1, 0);
|
|
}
|
|
|
|
TEST(MacroTest, DISABLED_getTrainingBase)
|
|
{
|
|
EXPECT_EQ(1, 0);
|
|
}
|
|
|
|
TEST(MacroTest, DISABLED_morphCreepColonies)
|
|
{
|
|
EXPECT_EQ(1, 0);
|
|
}
|
|
|
|
TEST(MacroTest, DISABLED_onUnitComplete)
|
|
{
|
|
EXPECT_EQ(1, 0);
|
|
}
|
|
|
|
TEST(MacroTest, DISABLED_onUnitCreate)
|
|
{
|
|
EXPECT_EQ(1, 0);
|
|
}
|
|
|
|
TEST(MacroTest, DISABLED_onUnitDestroy)
|
|
{
|
|
EXPECT_EQ(1, 0);
|
|
}
|
|
|
|
TEST(MacroTest, DISABLED_onUnitDiscover)
|
|
{
|
|
EXPECT_EQ(1, 0);
|
|
}
|
|
|
|
TEST(MacroTest, DISABLED_onUnitMorph)
|
|
{
|
|
EXPECT_EQ(1, 0);
|
|
}
|
|
|
|
TEST(MacroTest, DISABLED_onUnitShow)
|
|
{
|
|
Unit u = Unit();
|
|
EXPECT_EQ(1, 0);
|
|
}
|
|
|
|
TEST(MacroTest, queueCount)
|
|
{
|
|
BWAPI::UnitType unit = BWAPI::UnitTypes::Zerg_Drone;
|
|
EXPECT_EQ(Macro::queueCount(unit), 0);
|
|
|
|
Macro::queue.push_back(QueueEntry(unit, false, 0.0));
|
|
Macro::queue.push_back(QueueEntry(unit, false, 0.0));
|
|
EXPECT_EQ(Macro::queueCount(unit), 2);
|
|
}
|
|
|
|
TEST(MacroTest, queueHasTech)
|
|
{
|
|
BWAPI::TechType tech = BWAPI::TechTypes::Burrowing;
|
|
EXPECT_FALSE(Macro::queueHas(tech));
|
|
|
|
Macro::queue.push_back(QueueEntry(tech, false, 0.0));
|
|
EXPECT_TRUE(Macro::queueHas(tech));
|
|
}
|
|
|
|
TEST(MacroTest, queueHasUnit)
|
|
{
|
|
Macro::queue.clear();
|
|
BWAPI::UnitType unit = BWAPI::UnitTypes::Zerg_Drone;
|
|
EXPECT_FALSE(Macro::queueHas(unit));
|
|
|
|
Macro::queue.push_back(QueueEntry(unit, false, 0.0));
|
|
EXPECT_TRUE(Macro::queueHas(unit));
|
|
}
|
|
|
|
TEST(MacroTest, queueHasUpgrade)
|
|
{
|
|
BWAPI::UpgradeType upgrade = BWAPI::UpgradeTypes::Adrenal_Glands;
|
|
EXPECT_FALSE(Macro::queueHas(upgrade));
|
|
|
|
Macro::queue.push_back(QueueEntry(upgrade, false, 0.0));
|
|
EXPECT_TRUE(Macro::queueHas(upgrade));
|
|
}
|
|
|
|
TEST(MacroTest, setEnemyId)
|
|
{
|
|
int enemyId = 2;
|
|
Macro::setEnemyID(enemyId);
|
|
// check if the enemy id is in the enemyIDs vector
|
|
EXPECT_TRUE(std::find(Macro::enemyIDs.begin(), Macro::enemyIDs.end(), enemyId) != Macro::enemyIDs.end());
|
|
}
|
|
|
|
TEST(MacroTest, DISABLED_setLastAttack)
|
|
{
|
|
int lastAttackFrame = 2;
|
|
Macro::setLastAttack(lastAttackFrame);
|
|
EXPECT_EQ(Macro::lastAttack, lastAttackFrame);
|
|
}
|
|
|
|
TEST(MacroTest, DISABLED_setLastBuildLocation)
|
|
{
|
|
Macro::setLastBuildLocation(tp1);
|
|
EXPECT_EQ(Macro::lastBuildLocation.x, tp1.x);
|
|
EXPECT_EQ(Macro::lastBuildLocation.y, tp1.y);
|
|
}
|
|
|
|
TEST(MacroTest, DISABLED_setMacroHatch)
|
|
{
|
|
Macro::setMacroHatch(false);
|
|
EXPECT_EQ(Macro::macroHatch, false);
|
|
|
|
Macro::setMacroHatch(true);
|
|
EXPECT_EQ(Macro::macroHatch, true);
|
|
}
|
|
|
|
TEST(MacroTest, DISABLED_setNewBase)
|
|
{
|
|
Macro::setNewBase(false);
|
|
EXPECT_EQ(Macro::newBase, false);
|
|
|
|
Macro::setNewBase(true);
|
|
EXPECT_EQ(Macro::newBase, true);
|
|
}
|
|
|
|
TEST(MacroTest, DISABLED_setScouts)
|
|
{
|
|
EXPECT_EQ(int(Macro::scouts.size()), 0);
|
|
|
|
Macro::setSelfID(selfID);
|
|
CUnit overlord = CUnit();
|
|
Unit u = Unit();
|
|
}
|
|
|
|
TEST(MacroTest, setSelfID)
|
|
{
|
|
Macro::setSelfID(selfID);
|
|
EXPECT_EQ(Macro::selfID, selfID);
|
|
}
|
|
|
|
TEST(MacroTest, setStopProduction)
|
|
{
|
|
Macro::setStopProduction(false);
|
|
EXPECT_EQ(Macro::stopProduction, false);
|
|
|
|
Macro::setStopProduction(true);
|
|
EXPECT_EQ(Macro::stopProduction, true);
|
|
}
|
|
}
|
|
|
|
class MacroTestFixture : ::testing::Test
|
|
{
|
|
protected:
|
|
MacroTestFixture()
|
|
{
|
|
|
|
}
|
|
}; |