MCPcopy Create free account
hub / github.com/bwapi/bwapi / genUnitTypeTest

Function genUnitTypeTest

bwapi/DocumentationGen/unittypestestgen.cpp:5–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3#include <set>
4
5void genUnitTypeTest()
6{
7 std::ofstream of("testUnitTypes.txt");
8 of.setf(std::ios::showpoint);
9 of.setf(std::ios::boolalpha);
10 std::set<BWAPI::UnitType> types(BWAPI::UnitTypes::allUnitTypes().begin(), BWAPI::UnitTypes::allUnitTypes().end());
11 for (auto t : types)
12 {
13 of << tab(2) << "TEST_METHOD(UnitType" << t << ")\n";
14 of << tab(2) << "{\n";
15 of << tab(3) << "auto t = BWAPI::UnitTypes::" << t << ";\n";
16 of << tab(3) << "Assert_enum(" << t << ");\n\n";
17
18#define ASS_EQ(n) of << tab(3) << "Assert_" #n "(" << t.n() << ");\n"
19
20 ASS_EQ(getName);
21 of << tab(3) << "Assert::AreEqual(t.c_str(), t.getName().c_str());\n";
22 ASS_EQ(getRace);
23 of << tab(3) << "Assert_whatBuilds(" << t.whatBuilds().first << ", " << t.whatBuilds().second << ");\n";
24 of << tab(3) << "AssertSetEquals(" << mapToString(t.requiredUnits(), "BWAPI::UnitTypes::") << ", t.requiredUnits());\n";
25 ASS_EQ(requiredTech);
26 ASS_EQ(cloakingTech);
27 of << tab(3) << "AssertSetEquals(" << setToString(t.abilities(), "BWAPI::TechTypes::") << ", t.abilities());\n";
28 of << tab(3) << "AssertSetEquals(" << setToString(t.upgrades(), "BWAPI::UpgradeTypes::") << ", t.upgrades());\n";
29 ASS_EQ(armorUpgrade);
30 ASS_EQ(maxHitPoints);
31 ASS_EQ(maxShields);
32 ASS_EQ(maxEnergy);
33 ASS_EQ(armor);
34 ASS_EQ(mineralPrice);
35 ASS_EQ(gasPrice);
36 ASS_EQ(buildTime);
37 ASS_EQ(supplyRequired);
38 ASS_EQ(supplyProvided);
39 ASS_EQ(spaceRequired);
40 ASS_EQ(spaceProvided);
41 ASS_EQ(buildScore);
42 ASS_EQ(destroyScore);
43 ASS_EQ(size);
44 ASS_EQ(tileWidth);
45 ASS_EQ(tileHeight);
46 of << tab(3) << "Assert_tileSize(BWAPI::TilePosition" << t.tileSize() << ");\n";
47 of << tab(3) << "Assert::AreEqual(BWAPI::TilePosition(t.tileWidth(), t.tileHeight()), t.tileSize());\n";
48 ASS_EQ(dimensionLeft);
49 ASS_EQ(dimensionUp);
50 ASS_EQ(dimensionRight);
51 ASS_EQ(dimensionDown);
52 ASS_EQ(width);
53 of << tab(3) << "Assert::AreEqual(t.dimensionLeft() + 1 + t.dimensionRight(), t.width());\n";
54 ASS_EQ(height);
55 of << tab(3) << "Assert::AreEqual(t.dimensionUp() + 1 + t.dimensionDown(), t.height());\n";
56 ASS_EQ(seekRange);
57 ASS_EQ(sightRange);
58 ASS_EQ(groundWeapon);
59 ASS_EQ(maxGroundHits);
60 ASS_EQ(airWeapon);
61 ASS_EQ(maxAirHits);
62 ASS_EQ(topSpeed);

Callers 1

mainFunction · 0.85

Calls 7

tabFunction · 0.85
mapToStringFunction · 0.85
setToStringFunction · 0.85
beginMethod · 0.80
endMethod · 0.80
whatBuildsMethod · 0.80
tileSizeMethod · 0.80

Tested by

no test coverage detected