| 128 | |
| 129 | } |
| 130 | void CancelTrainTest::update() |
| 131 | { |
| 132 | if (running == false) return; |
| 133 | if (fail) |
| 134 | { |
| 135 | running = false; |
| 136 | return; |
| 137 | } |
| 138 | int thisFrame = Broodwar->getFrameCount(); |
| 139 | BWAssert(thisFrame==nextFrame); |
| 140 | BWAssertF(producer!=NULL,{fail=true;return;}); |
| 141 | nextFrame++; |
| 142 | Broodwar->setScreenPosition(producer->getPosition() - Position(320,240)); |
| 143 | if (state==Start) |
| 144 | { |
| 145 | BWAssertF(producer->isTraining()==true,{fail=true;return;}); |
| 146 | BWAssertF(producer->isConstructing()==false,{fail=true;return;}); |
| 147 | BWAssertF(producer->isIdle()==false,{fail=true;return;}); |
| 148 | BWAssertF(producer->isLifted()==false,{fail=true;return;}); |
| 149 | BWAssertF(verifyTrainingQueue(),{log("Error training queue failed at %u frame %d",__LINE__,thisFrame-startFrame);fail=true;return;}); |
| 150 | BWAssertF(Broodwar->self()->minerals() == correctMineralCount,{fail=true;return;}); |
| 151 | BWAssertF(Broodwar->self()->gas() == correctGasCount,{fail=true;return;}); |
| 152 | BWAssertF(Broodwar->self()->supplyUsed() == correctSupplyUsedCount,{log("Error supply used %d != %d",Broodwar->self()->supplyUsed(),correctSupplyUsedCount);fail=true;return;}); |
| 153 | BWAssertF(Broodwar->self()->allUnitCount(unitType2) == originalAllUnit2Count,{fail=true;return;}); |
| 154 | BWAssertF(Broodwar->self()->allUnitCount(unitType3) == originalAllUnit3Count,{fail=true;return;}); |
| 155 | if (thisFrame>=startFrame+15) |
| 156 | { |
| 157 | BWAssertF(producer->cancelTrain(0),{Broodwar->printf("%s",Broodwar->getLastError().c_str());fail=true;return;}); |
| 158 | correctTrainingQueue.pop_front(); |
| 159 | BWAssertF(verifyTrainingQueue(),{log("Error training queue failed at %u frame %d",__LINE__,thisFrame-startFrame-150);fail=true;return;}); |
| 160 | correctMineralCount = correctMineralCount + unitType1.mineralPrice(); |
| 161 | correctGasCount = correctGasCount + unitType1.gasPrice(); |
| 162 | correctSupplyUsedCount = correctSupplyUsedCount - unitType1.supplyRequired() + unitType2.supplyRequired(); |
| 163 | BWAssertF(Broodwar->self()->minerals() == correctMineralCount,{Broodwar->printf("%d != %d",Broodwar->self()->minerals(),correctMineralCount);fail=true;return;}); |
| 164 | BWAssertF(Broodwar->self()->gas() == correctGasCount,{fail=true;return;}); |
| 165 | BWAssertF(Broodwar->self()->supplyUsed() == correctSupplyUsedCount,{fail=true;return;}); |
| 166 | state = CancelledFirstSlot; |
| 167 | } |
| 168 | } |
| 169 | else if (state == CancelledFirstSlot) |
| 170 | { |
| 171 | BWAssertF(producer->isTraining()==true,{fail=true;return;}); |
| 172 | BWAssertF(producer->isConstructing()==false,{fail=true;return;}); |
| 173 | BWAssertF(producer->isIdle()==false,{fail=true;return;}); |
| 174 | BWAssertF(producer->isLifted()==false,{fail=true;return;}); |
| 175 | BWAssertF(verifyTrainingQueue(),{log("Error training queue failed at %u frame %d",__LINE__,thisFrame-startFrame-150);fail=true;return;}); |
| 176 | BWAssertF(Broodwar->self()->minerals() == correctMineralCount,{fail=true;return;}); |
| 177 | BWAssertF(Broodwar->self()->gas() == correctGasCount,{fail=true;return;}); |
| 178 | BWAssertF(Broodwar->self()->supplyUsed() == correctSupplyUsedCount,{log("Error supply used %d: %d != %d",thisFrame-startFrame-150,Broodwar->self()->supplyUsed(),correctSupplyUsedCount);}); |
| 179 | if (thisFrame>=startFrame+30) |
| 180 | { |
| 181 | BWAssertF(producer->cancelTrain(),{Broodwar->printf("%s",Broodwar->getLastError().c_str());fail=true;return;}); |
| 182 | correctTrainingQueue.pop_back(); |
| 183 | BWAssertF(verifyTrainingQueue(),{log("Error training queue failed at %u frame %d",__LINE__,thisFrame-startFrame-30);fail=true;return;}); |
| 184 | correctMineralCount = correctMineralCount + unitType3.mineralPrice(); |
| 185 | correctGasCount = correctGasCount + unitType3.gasPrice(); |
| 186 | BWAssertF(Broodwar->self()->minerals() == correctMineralCount,{fail=true;return;}); |
| 187 | BWAssertF(Broodwar->self()->gas() == correctGasCount,{fail=true;return;}); |
nothing calls this directly
no test coverage detected