2023-09-15 16:34:07 -05:00
|
|
|
#include <unity/unity.h>
|
|
|
|
#include <unity/unity_internals.h>
|
|
|
|
#include "../src/algorithm.hpp"
|
2023-09-15 12:43:32 -05:00
|
|
|
|
2023-09-15 16:34:07 -05:00
|
|
|
void setUp() { ; }
|
|
|
|
void tearDown() { ; }
|
2023-09-15 12:43:32 -05:00
|
|
|
|
2023-09-15 16:34:07 -05:00
|
|
|
Graph testGraph;
|
|
|
|
|
2023-09-15 17:01:51 -05:00
|
|
|
void test_GraphReadsIn(void) {
|
2023-09-15 16:34:07 -05:00
|
|
|
testGraph = ReadInGraph("test/input/graphPosLittle");
|
|
|
|
TEST_ASSERT_EQUAL_INT(10, testGraph.nodeCount);
|
2023-09-15 12:43:32 -05:00
|
|
|
}
|
|
|
|
|
2023-09-15 17:01:51 -05:00
|
|
|
void test_AllVerticesAdded(void) {
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
TEST_ASSERT_EQUAL_INT(i, testGraph.vertices.at(i).nodeNumber);
|
|
|
|
}
|
2023-09-15 12:43:32 -05:00
|
|
|
}
|
|
|
|
|
2023-09-15 17:01:51 -05:00
|
|
|
void test_AllEdgesAdded(void) {
|
|
|
|
// Edges for vertex 1
|
|
|
|
TEST_ASSERT_EQUAL_INT(7, testGraph.vertices.at(0).edges.at(0).destination->nodeNumber + 1);
|
|
|
|
TEST_ASSERT_EQUAL_INT(2, testGraph.vertices.at(0).edges.at(1).destination->nodeNumber + 1);
|
|
|
|
// Edges for vertex 2
|
|
|
|
TEST_ASSERT_EQUAL_INT(7, testGraph.vertices.at(1).edges.at(0).destination->nodeNumber + 1);
|
|
|
|
TEST_ASSERT_EQUAL_INT(5, testGraph.vertices.at(1).edges.at(1).destination->nodeNumber + 1);
|
|
|
|
TEST_ASSERT_EQUAL_INT(1, testGraph.vertices.at(1).edges.at(2).destination->nodeNumber + 1);
|
|
|
|
// Edges for vertex 3
|
|
|
|
TEST_ASSERT_EQUAL_INT(6, testGraph.vertices.at(2).edges.at(0).destination->nodeNumber + 1);
|
|
|
|
TEST_ASSERT_EQUAL_INT(1, testGraph.vertices.at(2).edges.at(1).destination->nodeNumber + 1);
|
|
|
|
TEST_ASSERT_EQUAL_INT(5, testGraph.vertices.at(2).edges.at(2).destination->nodeNumber + 1);
|
|
|
|
// Edges for vertex 4
|
|
|
|
TEST_ASSERT_EQUAL_INT(8, testGraph.vertices.at(3).edges.at(0).destination->nodeNumber + 1);
|
|
|
|
TEST_ASSERT_EQUAL_INT(10, testGraph.vertices.at(3).edges.at(1).destination->nodeNumber + 1);
|
|
|
|
// Edges for vertex 5
|
|
|
|
TEST_ASSERT_EQUAL_INT(3, testGraph.vertices.at(4).edges.at(0).destination->nodeNumber + 1);
|
|
|
|
TEST_ASSERT_EQUAL_INT(8, testGraph.vertices.at(4).edges.at(1).destination->nodeNumber + 1);
|
|
|
|
TEST_ASSERT_EQUAL_INT(7, testGraph.vertices.at(4).edges.at(2).destination->nodeNumber + 1);
|
|
|
|
// Edges for vertex 6
|
|
|
|
TEST_ASSERT_EQUAL_INT(3, testGraph.vertices.at(5).edges.at(0).destination->nodeNumber + 1);
|
|
|
|
// Edges for vertex 7
|
|
|
|
TEST_ASSERT_EQUAL_INT(2, testGraph.vertices.at(6).edges.at(0).destination->nodeNumber + 1);
|
|
|
|
TEST_ASSERT_EQUAL_INT(9, testGraph.vertices.at(6).edges.at(1).destination->nodeNumber + 1);
|
|
|
|
TEST_ASSERT_EQUAL_INT(1, testGraph.vertices.at(6).edges.at(2).destination->nodeNumber + 1);
|
|
|
|
// Edges for vertex 8
|
|
|
|
TEST_ASSERT_EQUAL_INT(5, testGraph.vertices.at(7).edges.at(0).destination->nodeNumber + 1);
|
|
|
|
TEST_ASSERT_EQUAL_INT(4, testGraph.vertices.at(7).edges.at(1).destination->nodeNumber + 1);
|
|
|
|
// Edges for vertex 9
|
|
|
|
TEST_ASSERT_EQUAL_INT(6, testGraph.vertices.at(8).edges.at(0).destination->nodeNumber + 1);
|
|
|
|
TEST_ASSERT_EQUAL_INT(10, testGraph.vertices.at(8).edges.at(1).destination->nodeNumber + 1);
|
|
|
|
TEST_ASSERT_EQUAL_INT(7, testGraph.vertices.at(8).edges.at(2).destination->nodeNumber + 1);
|
|
|
|
// Edges for vertex 10
|
|
|
|
TEST_ASSERT_EQUAL_INT(4, testGraph.vertices.at(9).edges.at(0).destination->nodeNumber + 1);
|
|
|
|
TEST_ASSERT_EQUAL_INT(9, testGraph.vertices.at(9).edges.at(1).destination->nodeNumber + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(void) {
|
2023-09-15 12:43:32 -05:00
|
|
|
UNITY_BEGIN();
|
2023-09-15 17:01:51 -05:00
|
|
|
RUN_TEST(test_GraphReadsIn);
|
2023-09-15 16:34:07 -05:00
|
|
|
RUN_TEST(test_AllVerticesAdded);
|
|
|
|
RUN_TEST(test_AllEdgesAdded);
|
2023-09-15 12:43:32 -05:00
|
|
|
return UNITY_END();
|
|
|
|
}
|
|
|
|
|