| 35 | FAILTEST(builderType!=UnitTypes::Unknown); |
| 36 | } |
| 37 | void BuildTest::start() |
| 38 | { |
| 39 | if (fail) return; |
| 40 | running = true; |
| 41 | |
| 42 | int builderCount = Broodwar->self()->completedUnitCount(builderType); |
| 43 | FAILTEST(builderCount>=1); |
| 44 | for (Unit u : Broodwar->self()->getUnits()) |
| 45 | { |
| 46 | if (u->getType()==builderType && u->getAddon()==NULL) |
| 47 | { |
| 48 | builder = u; |
| 49 | break; |
| 50 | } |
| 51 | } |
| 52 | FAILTEST(builder!=NULL); |
| 53 | FAILTEST(builder->isIdle()==true); |
| 54 | |
| 55 | |
| 56 | if (unitType.isAddon()) |
| 57 | { |
| 58 | FAILTEST(builder->buildAddon(unitType)); |
| 59 | } |
| 60 | else |
| 61 | { |
| 62 | if (unitType==UnitTypes::Protoss_Pylon) |
| 63 | { |
| 64 | buildLocation = BuildingPlacer::getBuildLocationNear(builder->getTilePosition(), unitType, 4); |
| 65 | } |
| 66 | else if ((unitType.getRace()==Races::Zerg && unitType.isResourceDepot()) || unitType==UnitTypes::Protoss_Gateway) |
| 67 | { |
| 68 | buildLocation = BuildingPlacer::getBuildLocationNear(builder->getTilePosition(), unitType, 2); |
| 69 | } |
| 70 | { |
| 71 | buildLocation = BuildingPlacer::getBuildLocationNear(builder->getTilePosition(), unitType, 1); |
| 72 | } |
| 73 | FAILTEST(builder->build(unitType, buildLocation)); |
| 74 | } |
| 75 | FAILTEST( !builder->isIdle() ); |
| 76 | FAILTEST( builder->isConstructing() ); |
| 77 | BWAssertF(builder->getBuildType()==unitType, |
| 78 | { |
| 79 | log("Error: %s != %s",builder->getBuildType().c_str(),unitType.c_str()); |
| 80 | fail=true; |
| 81 | return; |
| 82 | }); |
| 83 | |
| 84 | nextFrame = Broodwar->getFrameCount(); |
| 85 | previousUnitCount = Broodwar->self()->completedUnitCount(unitType); |
| 86 | |
| 87 | } |
| 88 | void BuildTest::update() |
| 89 | { |
| 90 | if (running == false) return; |
nothing calls this directly
no test coverage detected