6 #include <gtest/gtest.h>
8 namespace etrobocon2018_test {
11 TEST(NodeTest, getInitialValueOfNodeIDTest)
14 std::int8_t expected = 0;
18 ASSERT_EQ(expected, actual);
22 TEST(NodeTest, getInitialValueOfBlockExistsTest)
32 TEST(NodeTest, getInitialValueOfPositionTest)
35 std::int8_t expectedX = 0;
36 std::int8_t expectedY = 0;
41 ASSERT_EQ(expectedX, actualX);
42 ASSERT_EQ(expectedY, actualY);
46 TEST(NodeTest, getValueOfNodeIDTest)
49 std::int8_t expected = 10;
54 ASSERT_EQ(expected, actual);
58 TEST(NodeTest, initializeValueOfNodeIDTest)
60 std::int8_t expected = 9;
65 ASSERT_EQ(expected, actual);
69 TEST(NodeTest, getValueOfBlockExistsTest)
80 TEST(NodeTest, getValueOfPositionTest)
83 std::int8_t expectedX = 5;
84 std::int8_t expectedY = 8;
90 ASSERT_EQ(expectedX, actualX);
91 ASSERT_EQ(expectedY, actualY);
95 TEST(NodeTest, getValueOfNeighborListTest)
101 std::vector<Node*> expected = {&nodeA, &nodeB};
106 ASSERT_EQ(&expected, actual);
107 ASSERT_EQ(expected.at(0), actual->at(0));
109 expected.at(0)->setNodeID(3);
110 ASSERT_EQ(&expected, actual);
111 ASSERT_EQ(expected.at(0), actual->at(0));
112 ASSERT_EQ(expected.at(0)->getNodeID(), actual->at(0)->getNodeID());
116 TEST(NodeTest, getValueOf3NeighborListTest)
122 std::vector<Node*> neighbors1 = {&node2};
123 std::vector<Node*> neighbors2 = {&node1, &node3};
124 std::vector<Node*> neighbors3 = {&node2};
134 ASSERT_EQ(&neighbors1, actual1);
135 ASSERT_EQ(&neighbors2, actual2);
136 ASSERT_EQ(&neighbors3, actual3);
138 ASSERT_EQ(&node1, actual1->at(0)->
getNeighbors()->at(0));
139 ASSERT_EQ(&node2, actual2->at(0)->
getNeighbors()->at(0));
140 ASSERT_EQ(&node2, actual2->at(1)->
getNeighbors()->at(0));
141 ASSERT_EQ(&node3, actual3->at(0)->
getNeighbors()->at(1));
145 TEST(NodeTest, getValueOfNeighborListOf3x3Test)
147 std::vector<Node*> blockAreaNodePtrList(9);
148 std::vector<Node> blockAreaNodeList(9);
150 for (std::int8_t i = 0; i < 9; i++)
153 blockAreaNodeList[i] = currentNode;
154 blockAreaNodePtrList[i] = &blockAreaNodeList[i];
156 std::vector<Node*>* blockAreaNodePtrListPtr = &blockAreaNodePtrList;
159 std::vector<Node*> neighborsOfNode0;
160 std::vector<Node*> neighborsOfNode1;
161 std::vector<Node*> neighborsOfNode2;
163 std::vector<Node*> neighborsOfNode3;
164 std::vector<Node*> neighborsOfNode4;
165 std::vector<Node*> neighborsOfNode5;
167 std::vector<Node*> neighborsOfNode6;
168 std::vector<Node*> neighborsOfNode7;
169 std::vector<Node*> neighborsOfNode8;
172 int numbers0[2] = {1, 3};
173 for (
int i = 0; i < 2; i++)
175 neighborsOfNode0.push_back(blockAreaNodePtrListPtr->at(numbers0[i]));
177 int numbers1[3] = {0, 2, 4};
178 for (
int i = 0; i < 3; i++)
180 neighborsOfNode1.push_back(blockAreaNodePtrListPtr->at(numbers1[i]));
182 int numbers2[2] = {1, 5};
183 for (
int i = 0; i < 2; i++)
185 neighborsOfNode2.push_back(blockAreaNodePtrListPtr->at(numbers2[i]));
189 int numbers3[3] = {0, 4, 6};
190 for (
int i = 0; i < 3; i++)
192 neighborsOfNode3.push_back(blockAreaNodePtrListPtr->at(numbers3[i]));
194 int numbers4[4] = {1, 3, 5, 7};
195 for (
int i = 0; i < 4; i++)
197 neighborsOfNode4.push_back(blockAreaNodePtrListPtr->at(numbers4[i]));
199 int numbers5[3] = {2, 4, 8};
200 for (
int i = 0; i < 3; i++)
202 neighborsOfNode5.push_back(blockAreaNodePtrListPtr->at(numbers5[i]));
206 int numbers6[2] = {3, 7};
207 for (
int i = 0; i < 2; i++)
209 neighborsOfNode6.push_back(blockAreaNodePtrListPtr->at(numbers6[i]));
211 int numbers7[3] = {4, 6, 8};
212 for (
int i = 0; i < 3; i++)
214 neighborsOfNode7.push_back(blockAreaNodePtrListPtr->at(numbers7[i]));
216 int numbers8[2] = {5, 7};
217 for (
int i = 0; i < 2; i++)
219 neighborsOfNode8.push_back(blockAreaNodePtrListPtr->at(numbers8[i]));
223 blockAreaNodePtrListPtr->at(0)->
setNeighbors(&neighborsOfNode0);
224 blockAreaNodePtrListPtr->at(1)->setNeighbors(&neighborsOfNode1);
225 blockAreaNodePtrListPtr->at(2)->setNeighbors(&neighborsOfNode2);
227 blockAreaNodePtrListPtr->at(3)->setNeighbors(&neighborsOfNode3);
228 blockAreaNodePtrListPtr->at(4)->setNeighbors(&neighborsOfNode4);
229 blockAreaNodePtrListPtr->at(5)->setNeighbors(&neighborsOfNode5);
231 blockAreaNodePtrListPtr->at(6)->setNeighbors(&neighborsOfNode6);
232 blockAreaNodePtrListPtr->at(7)->setNeighbors(&neighborsOfNode7);
233 blockAreaNodePtrListPtr->at(8)->setNeighbors(&neighborsOfNode8);
236 ASSERT_EQ(blockAreaNodePtrListPtr->at(0)->getNodeID(), blockAreaNodeList[1].getNeighbors()->at(0)->getNodeID());
238 ASSERT_EQ(&blockAreaNodeList[0], blockAreaNodeList[1].getNeighbors()->at(0));
239 ASSERT_EQ(&blockAreaNodeList[0], neighborsOfNode1[0]);
240 ASSERT_EQ(blockAreaNodeList[1].getNodeID(), blockAreaNodeList[0].getNeighbors()->at(0)->getNodeID());
241 ASSERT_EQ(&blockAreaNodeList[1], blockAreaNodeList[0].getNeighbors()->at(0));
244 ASSERT_EQ(blockAreaNodePtrListPtr->at(4), blockAreaNodePtrListPtr->at(1)->getNeighbors()->at(2));
245 ASSERT_EQ(blockAreaNodePtrListPtr->at(4), blockAreaNodePtrListPtr->at(3)->getNeighbors()->at(1));
246 ASSERT_EQ(blockAreaNodePtrListPtr->at(4), blockAreaNodePtrListPtr->at(5)->getNeighbors()->at(1));
247 ASSERT_EQ(blockAreaNodePtrListPtr->at(4), blockAreaNodePtrListPtr->at(7)->getNeighbors()->at(0));
250 ASSERT_EQ(blockAreaNodePtrListPtr->at(4), blockAreaNodePtrListPtr->at(0)->getNeighbors()->at(0)->getNeighbors()->at(2));
251 ASSERT_EQ(blockAreaNodePtrListPtr->at(4), blockAreaNodePtrListPtr->at(2)->getNeighbors()->at(1)->getNeighbors()->at(1));
252 ASSERT_EQ(blockAreaNodePtrListPtr->at(4), blockAreaNodePtrListPtr->at(6)->getNeighbors()->at(0)->getNeighbors()->at(1));
253 ASSERT_EQ(blockAreaNodePtrListPtr->at(4), blockAreaNodePtrListPtr->at(8)->getNeighbors()->at(1)->getNeighbors()->at(0));
257 TEST(NodeTest, getValueOfNeighborListOf4x4Test)
276 std::vector<Node*> neighbors0 = {&node1, &node4};
277 std::vector<Node*> neighbors1 = {&node0, &node2, &node5};
278 std::vector<Node*> neighbors2 = {&node1, &node3, &node6};
279 std::vector<Node*> neighbors3 = {&node2, &node7};
280 std::vector<Node*> neighbors4 = {&node0, &node5, &node8};
281 std::vector<Node*> neighbors5 = {&node1, &node4, &node6, &node9};
282 std::vector<Node*> neighbors6 = {&node2, &node5, &node7, &node10};
283 std::vector<Node*> neighbors7 = {&node3, &node6, &node11};
284 std::vector<Node*> neighbors8 = {&node4, &node9, &node12};
285 std::vector<Node*> neighbors9 = {&node5, &node8, &node10, &node13};
286 std::vector<Node*> neighbors10 = {&node6, &node9, &node11, &node14};
287 std::vector<Node*> neighbors11 = {&node7, &node10, &node15};
288 std::vector<Node*> neighbors12 = {&node8, &node13};
289 std::vector<Node*> neighbors13 = {&node9, &node12, &node14};
290 std::vector<Node*> neighbors14 = {&node10, &node13, &node15};
291 std::vector<Node*> neighbors15 = {&node11, &node14};
327 ASSERT_EQ(&neighbors0, actual0);
328 ASSERT_EQ(&neighbors1, actual1);
329 ASSERT_EQ(&neighbors2, actual2);
330 ASSERT_EQ(&neighbors3, actual3);
331 ASSERT_EQ(&neighbors4, actual4);
332 ASSERT_EQ(&neighbors5, actual5);
333 ASSERT_EQ(&neighbors6, actual6);
334 ASSERT_EQ(&neighbors7, actual7);
335 ASSERT_EQ(&neighbors8, actual8);
336 ASSERT_EQ(&neighbors9, actual9);
337 ASSERT_EQ(&neighbors10, actual10);
338 ASSERT_EQ(&neighbors11, actual11);
339 ASSERT_EQ(&neighbors12, actual12);
340 ASSERT_EQ(&neighbors13, actual13);
341 ASSERT_EQ(&neighbors14, actual14);
342 ASSERT_EQ(&neighbors15, actual15);
346 TEST(NodeTest, getValueOfNeighborListOfETRobocon2018Test)
348 std::vector<std::vector<int>> neighborsIDList = {
365 int nodeCount = neighborsIDList.size();
367 std::vector<Node> nodes(nodeCount);
368 std::vector<Node*> nodePtrs(nodeCount);
369 for (
int i = 0; i < nodeCount; i++)
371 nodes[i].setNodeID(i);
372 nodePtrs[i] = &nodes[i];
375 std::vector<std::vector<Node*>> neighbors(nodeCount);
376 for (
int i = 0; i < nodeCount; i++)
378 for (
int nodeID : neighborsIDList[i])
380 neighbors[i].push_back(nodePtrs[nodeID]);
383 for (
int i = 0; i < nodeCount; i++)
385 nodePtrs[i]->setNeighbors(&neighbors[i]);
388 auto actual0 = nodePtrs[0]->getNeighbors();
389 auto actual1 = nodePtrs[1]->getNeighbors();
390 auto actual2 = nodePtrs[2]->getNeighbors();
391 auto actual3 = nodePtrs[3]->getNeighbors();
392 auto actual4 = nodePtrs[4]->getNeighbors();
393 auto actual5 = nodePtrs[5]->getNeighbors();
394 auto actual6 = nodePtrs[6]->getNeighbors();
395 auto actual7 = nodePtrs[7]->getNeighbors();
396 auto actual8 = nodePtrs[8]->getNeighbors();
397 auto actual9 = nodePtrs[9]->getNeighbors();
398 auto actual10 = nodePtrs[10]->getNeighbors();
399 auto actual11 = nodePtrs[11]->getNeighbors();
400 auto actual12 = nodePtrs[12]->getNeighbors();
401 auto actual13 = nodePtrs[13]->getNeighbors();
402 auto actual14 = nodePtrs[14]->getNeighbors();
403 auto actual15 = nodePtrs[15]->getNeighbors();
405 ASSERT_EQ(&neighbors[0], actual0);
406 ASSERT_EQ(&neighbors[1], actual1);
407 ASSERT_EQ(&neighbors[2], actual2);
408 ASSERT_EQ(&neighbors[3], actual3);
409 ASSERT_EQ(&neighbors[4], actual4);
410 ASSERT_EQ(&neighbors[5], actual5);
411 ASSERT_EQ(&neighbors[6], actual6);
412 ASSERT_EQ(&neighbors[7], actual7);
413 ASSERT_EQ(&neighbors[8], actual8);
414 ASSERT_EQ(&neighbors[9], actual9);
415 ASSERT_EQ(&neighbors[10], actual10);
416 ASSERT_EQ(&neighbors[11], actual11);
417 ASSERT_EQ(&neighbors[12], actual12);
418 ASSERT_EQ(&neighbors[13], actual13);
419 ASSERT_EQ(&neighbors[14], actual14);
420 ASSERT_EQ(&neighbors[15], actual15);
422 ASSERT_EQ(&neighbors[10], actual0->at(1)->getNeighbors()->at(1)->getNeighbors()->at(2)->getNeighbors()->at(3)->getNeighbors());
426 TEST(NodeTest, getValueOfNeighborListOfETRobocon2017Test)
428 std::vector<std::vector<int>> neighborsIDList = {
444 int nodeCount = neighborsIDList.size();
446 std::vector<Node> nodes(nodeCount);
447 std::vector<Node*> nodePtrs(nodeCount);
448 for (
int i = 0; i < nodeCount; i++)
450 nodes[i].setNodeID(i);
451 nodePtrs[i] = &nodes[i];
454 std::vector<std::vector<Node*>> neighbors(nodeCount);
455 for (
int i = 0; i < nodeCount; i++)
457 for (
int nodeID : neighborsIDList[i])
459 neighbors[i].push_back(nodePtrs[nodeID]);
462 for (
int i = 0; i < nodeCount; i++)
464 nodePtrs[i]->setNeighbors(&neighbors[i]);
467 auto actual0 = nodePtrs[0]->getNeighbors();
468 auto actual1 = nodePtrs[1]->getNeighbors();
469 auto actual2 = nodePtrs[2]->getNeighbors();
470 auto actual3 = nodePtrs[3]->getNeighbors();
471 auto actual4 = nodePtrs[4]->getNeighbors();
472 auto actual5 = nodePtrs[5]->getNeighbors();
473 auto actual6 = nodePtrs[6]->getNeighbors();
474 auto actual7 = nodePtrs[7]->getNeighbors();
475 auto actual8 = nodePtrs[8]->getNeighbors();
476 auto actual9 = nodePtrs[9]->getNeighbors();
477 auto actual10 = nodePtrs[10]->getNeighbors();
478 auto actual11 = nodePtrs[11]->getNeighbors();
479 auto actual12 = nodePtrs[12]->getNeighbors();
480 auto actual13 = nodePtrs[13]->getNeighbors();
481 auto actual14 = nodePtrs[14]->getNeighbors();
483 ASSERT_EQ(&neighbors[0], actual0);
484 ASSERT_EQ(&neighbors[1], actual1);
485 ASSERT_EQ(&neighbors[2], actual2);
486 ASSERT_EQ(&neighbors[3], actual3);
487 ASSERT_EQ(&neighbors[4], actual4);
488 ASSERT_EQ(&neighbors[5], actual5);
489 ASSERT_EQ(&neighbors[6], actual6);
490 ASSERT_EQ(&neighbors[7], actual7);
491 ASSERT_EQ(&neighbors[8], actual8);
492 ASSERT_EQ(&neighbors[9], actual9);
493 ASSERT_EQ(&neighbors[10], actual10);
494 ASSERT_EQ(&neighbors[11], actual11);
495 ASSERT_EQ(&neighbors[12], actual12);
496 ASSERT_EQ(&neighbors[13], actual13);
497 ASSERT_EQ(&neighbors[14], actual14);
void setPosition(std::int8_t x, std::int8_t y)
void setNodeID(std::int8_t nodeNumber)
std::int8_t getPositionX()
std::vector< Node * > * getNeighbors()
void setNeighbors(std::vector< Node * > *nodes)
TEST(AIAnswerArrayTest, construct)
void setHasBlock(bool exists)
std::int8_t getPositionY()