summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/eina_graph_suite.c46
1 files changed, 43 insertions, 3 deletions
diff --git a/src/tests/eina_graph_suite.c b/src/tests/eina_graph_suite.c
index bb4cdf1..14b21f8 100644
--- a/src/tests/eina_graph_suite.c
+++ b/src/tests/eina_graph_suite.c
@@ -33,7 +33,7 @@ START_TEST (test_eina_graph_simple_bfs)
unsigned int vsr[] = { 0, 5, 3 };
ck_assert(eina_graph_init() == 1);
- Eina_Graph *g = eina_graph_new(13, 2);
+ Eina_Graph *g = eina_graph_new(13, 2, EINA_FALSE);
ck_assert(g != NULL);
_feed_simple_graph(g);
@@ -73,7 +73,7 @@ START_TEST (test_eina_graph_simple_dfs)
unsigned int vss[] = { 0, 6, 4, 5, 3 };
ck_assert(eina_graph_init() == 1);
- Eina_Graph *g = eina_graph_new(13, 2);
+ Eina_Graph *g = eina_graph_new(13, 2, EINA_FALSE);
ck_assert(g != NULL);
_feed_simple_graph(g);
@@ -125,11 +125,13 @@ START_TEST (test_eina_graph_simple)
ck_assert(eina_graph_init() == 1);
ck_assert(eina_graph_init() == 2);
- Eina_Graph *g = eina_graph_new(13, 2);
+ Eina_Graph *g = eina_graph_new(13, 2, EINA_FALSE);
ck_assert(g != NULL);
_feed_simple_graph(g);
+ ck_assert(eina_graph_directed(g) == EINA_FALSE);
+
ck_assert(eina_graph_edge_add(g, -1, 3) == EINA_FALSE);
ck_assert(eina_graph_edge_add(g, 3, -1) == EINA_FALSE);
ck_assert(eina_graph_edge_add(g, 13, 3) == EINA_FALSE);
@@ -161,6 +163,44 @@ START_TEST (test_eina_graph_simple)
eina_graph_free(g);
+ g = eina_graph_new(13, 2, EINA_TRUE);
+ ck_assert(g != NULL);
+
+ _feed_simple_graph(g);
+
+ ck_assert(eina_graph_directed(g) == EINA_TRUE);
+
+ ck_assert(eina_graph_edge_add(g, -1, 3) == EINA_FALSE);
+ ck_assert(eina_graph_edge_add(g, 3, -1) == EINA_FALSE);
+ ck_assert(eina_graph_edge_add(g, 13, 3) == EINA_FALSE);
+ ck_assert(eina_graph_edge_add(g, 3, 13) == EINA_FALSE);
+
+ ck_assert(eina_graph_vertices_count(g) == 13);
+ ck_assert(eina_graph_edges_count(g) == 13);
+ ck_assert(eina_graph_degree(g, 4) == 1);
+ ck_assert(eina_graph_degree(g, 0) == 4);
+ ck_assert(eina_graph_degree(g, 15) == 0);
+ ck_assert(eina_graph_degree_max(g) == 4);
+ ck_assert(eina_graph_degree_avg(g) == 2.0);
+ ck_assert(eina_graph_self_loops(g) == 0);
+
+ ck_assert(eina_graph_edge_add(g, 0, 0) == EINA_TRUE);
+
+ ck_assert(eina_graph_vertices_count(g) == 13);
+ ck_assert(eina_graph_edges_count(g) == 14);
+ ck_assert(eina_graph_degree(g, 4) == 1);
+ ck_assert(eina_graph_degree(g, 0) == 5);
+ ck_assert(eina_graph_degree_max(g) == 5);
+ ck_assert(eina_graph_degree_avg(g) > 2.153);
+ ck_assert(eina_graph_degree_avg(g) < 2.154);
+ ck_assert(eina_graph_self_loops(g) == 1);
+
+ outf = fopen("/tmp/eina_graph_directed.dot", "w");
+ eina_graph_dot_write(g, outf);
+ fclose(outf);
+
+ eina_graph_free(g);
+
ck_assert(eina_graph_shutdown() == 1);
ck_assert(eina_graph_shutdown() == 0);
}