MCPcopy Create free account
hub / github.com/chrxh/alien / TEST_F

Function TEST_F

source/EngineTests/DefenderTests.cpp:34–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32};
33
34TEST_F(DefenderTests, attackerVsAntiAttacker)
35{
36 DataDescription data;
37 data.addCells({
38 CellDescription()
39 .setId(1)
40 .setPos({10.0f, 10.0f})
41 .setMaxConnections(2)
42 .setExecutionOrderNumber(0)
43 .setInputExecutionOrderNumber(5)
44 .setCellFunction(AttackerDescription().setMode(EnergyDistributionMode_TransmittersAndConstructors)),
45 CellDescription()
46 .setId(2)
47 .setPos({11.0f, 10.0f})
48 .setMaxConnections(1)
49 .setExecutionOrderNumber(5)
50 .setCellFunction(NerveDescription().setPulseMode(1))
51 .setSignal({1, 0, 0, 0, 0, 0, 0, 0}),
52 CellDescription()
53 .setId(3)
54 .setPos({9.0f, 10.0f})
55 .setMaxConnections(2)
56 .setExecutionOrderNumber(0)
57 .setCellFunction(NerveDescription()),
58 CellDescription()
59 .setId(4)
60 .setPos({7.0f, 10.0f})
61 .setMaxConnections(2)
62 .setExecutionOrderNumber(0)
63 .setCellFunction(DefenderDescription().setMode(DefenderMode_DefendAgainstAttacker)),
64 });
65 data.addConnection(1, 2);
66 data.addConnection(3, 4);
67
68 _simulationFacade->setSimulationData(data);
69 _simulationFacade->calcTimesteps(1);
70
71 auto actualData = _simulationFacade->getSimulationData();
72 auto actualAttacker = getCell(actualData, 1);
73
74 auto origTarget = getCell(data, 3);
75 auto actualTarget = getCell(actualData, 3);
76
77 EXPECT_TRUE(approxCompare(getEnergy(data), getEnergy(actualData)));
78 EXPECT_TRUE(actualAttacker.signal.channels[0] > NEAR_ZERO);
79 EXPECT_LT(origTarget.energy, actualTarget.energy + 0.1f);
80}
81
82TEST_F(DefenderTests, attackerVsAntiInjector)
83{

Callers

nothing calls this directly

Calls 14

AttackerDescriptionClass · 0.85
NerveDescriptionClass · 0.85
DefenderDescriptionClass · 0.85
GenomeDescriptionClass · 0.85
InjectorDescriptionClass · 0.85
setModeMethod · 0.80
setGenomeMethod · 0.80
CellDescriptionClass · 0.50
setSimulationDataMethod · 0.45

Tested by

no test coverage detected