blob: 27af514c87e91c7e880641f090c26e4fe82b29b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#include "graph.h"
#include <cgreen/cgreen.h>
#include <string.h>
Ensure(three_equals_three) {
assert_that(3, is_equal_to(3));
}
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) {
Graph *graph = graph_initialize();
char label = 'a';
Vertex *a = graph_add_vertex(graph, label);
assert_that(a, is_not_equal_to(NULL));
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_graph);
add_test(x, add_vertex_returns_a_new_vertex);
add_test(x, add_vertex_adds_max_number_of_verticies_to_graph);
return x;
}
|