summaryrefslogtreecommitdiff
path: root/src/03/graph_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/03/graph_test.c')
-rw-r--r--src/03/graph_test.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/03/graph_test.c b/src/03/graph_test.c
index 44a8715..27af514 100644
--- a/src/03/graph_test.c
+++ b/src/03/graph_test.c
@@ -6,10 +6,12 @@ Ensure(three_equals_three) {
assert_that(3, is_equal_to(3));
}
-Ensure(initialize_returns_a_new_vertex) {
+Ensure(initialize_returns_a_new_graph) {
Graph *graph = graph_initialize();
assert_that(graph, is_not_equal_to(NULL));
+ for (int i = 0; i < 128; ++i)
+ assert_that(graph->vertices[i], is_equal_to(NULL));
}
Ensure(add_vertex_returns_a_new_vertex) {
@@ -21,14 +23,25 @@ Ensure(add_vertex_returns_a_new_vertex) {
assert_that(graph->vertices[(int)label], is_equal_to(a));
}
+Ensure(add_vertex_adds_max_number_of_verticies_to_graph) {
+ Graph *graph = graph_initialize();
+
+ for (int i = 0; i < 128; ++i) {
+ Vertex *item = graph_add_vertex(graph, (char)i);
+ assert_that(item, is_not_equal_to(NULL));
+ assert_that(graph->vertices[i], is_equal_to(item));
+ }
+}
+
TestSuite *graph_tests() {
TestSuite *x = create_test_suite();
add_test(x, three_equals_three);
- add_test(x, initialize_returns_a_new_vertex);
+ add_test(x, initialize_returns_a_new_graph);
add_test(x, add_vertex_returns_a_new_vertex);
+ add_test(x, add_vertex_adds_max_number_of_verticies_to_graph);
return x;
}