| 37 | return true; |
| 38 | } |
| 39 | void CancelTrainTest::start() |
| 40 | { |
| 41 | if (fail) return; |
| 42 | running = true; |
| 43 | |
| 44 | int producerCount = Broodwar->self()->completedUnitCount(producerType); |
| 45 | BWAssertF(producerCount>=1,{fail=true;return;}); |
| 46 | for (Unit u : Broodwar->self()->getUnits()) |
| 47 | { |
| 48 | if (u->getType()==producerType) |
| 49 | { |
| 50 | producer = u; |
| 51 | break; |
| 52 | } |
| 53 | } |
| 54 | BWAssertF(producer!=NULL,{fail=true;return;}); |
| 55 | |
| 56 | originalMineralCount = Broodwar->self()->minerals(); |
| 57 | originalGasCount = Broodwar->self()->gas(); |
| 58 | originalSupplyUsedCount = Broodwar->self()->supplyUsed(); |
| 59 | originalAllUnit1Count = Broodwar->self()->allUnitCount(unitType1); |
| 60 | originalAllUnit2Count = Broodwar->self()->allUnitCount(unitType2); |
| 61 | originalAllUnit3Count = Broodwar->self()->allUnitCount(unitType3); |
| 62 | correctMineralCount = Broodwar->self()->minerals(); |
| 63 | correctGasCount = Broodwar->self()->gas(); |
| 64 | correctSupplyUsedCount = Broodwar->self()->supplyUsed(); |
| 65 | |
| 66 | BWAssertF(producer->isTraining()==false,{fail=true;return;}); |
| 67 | BWAssertF(producer->isConstructing()==false,{fail=true;return;}); |
| 68 | BWAssertF(producer->isIdle()==true,{fail=true;return;}); |
| 69 | BWAssertF(producer->isLifted()==false,{fail=true;return;}); |
| 70 | BWAssertF(producer->getTrainingQueue().empty()==true,{fail=true;return;}); |
| 71 | BWAssertF(producer->getRemainingTrainTime() == 0,{fail=true;return;}); |
| 72 | BWAssertF(Broodwar->self()->allUnitCount(unitType1) == originalAllUnit1Count,{fail=true;return;}); |
| 73 | BWAssertF(Broodwar->self()->allUnitCount(unitType2) == originalAllUnit2Count,{fail=true;return;}); |
| 74 | BWAssertF(Broodwar->self()->allUnitCount(unitType3) == originalAllUnit3Count,{fail=true;return;}); |
| 75 | |
| 76 | producer->train(unitType1); |
| 77 | correctMineralCount = correctMineralCount - unitType1.mineralPrice(); |
| 78 | correctGasCount = correctGasCount - unitType1.gasPrice(); |
| 79 | correctSupplyUsedCount = correctSupplyUsedCount + unitType1.supplyRequired(); |
| 80 | correctTrainingQueue.push_back(unitType1); |
| 81 | |
| 82 | BWAssertF(verifyTrainingQueue(),{fail=true;return;}); |
| 83 | BWAssertF(producer->isTraining()==true,{fail=true;return;}); |
| 84 | BWAssertF(producer->isConstructing()==false,{fail=true;return;}); |
| 85 | BWAssertF(producer->isIdle()==false,{fail=true;return;}); |
| 86 | BWAssertF(producer->isLifted()==false,{fail=true;return;}); |
| 87 | BWAssertF(producer->getTrainingQueue().size()==1,{fail=true;return;}); |
| 88 | BWAssertF(producer->getRemainingTrainTime() == unitType1.buildTime(),{fail=true;return;}); |
| 89 | BWAssertF(Broodwar->self()->minerals() == correctMineralCount,{Broodwar->printf("%d != %d",Broodwar->self()->minerals(), correctMineralCount);fail=true;return;}); |
| 90 | BWAssertF(Broodwar->self()->gas() == correctGasCount,{fail=true;return;}); |
| 91 | BWAssertF(Broodwar->self()->supplyUsed() == correctSupplyUsedCount,{fail=true;return;}); |
| 92 | |
| 93 | producer->train(unitType2); |
| 94 | correctMineralCount = correctMineralCount - unitType2.mineralPrice(); |
| 95 | correctGasCount = correctGasCount - unitType2.gasPrice(); |
| 96 | correctTrainingQueue.push_back(unitType2); |
nothing calls this directly
no test coverage detected