Commit 8737272

mo khan <mo.khan@gmail.com>
2020-09-07 19:55:54
feat: add function to init vertex
1 parent 5aaa100
Changed files (3)
src/03/graph.c
@@ -1,1 +1,8 @@
 #include "graph.h"
+#include <stdlib.h>
+
+Vertex *graph_initialize(char label) {
+  Vertex *item = malloc(sizeof(Vertex));
+  item->label = label;
+  return item;
+};
src/03/graph.h
@@ -0,0 +1,5 @@
+typedef struct {
+  char label;
+} Vertex;
+
+Vertex *graph_initialize(char label);
src/03/graph_test.c
@@ -6,6 +6,12 @@ Ensure(three_equals_three) {
   assert_that(3, is_equal_to(3));
 }
 
+Ensure(initialize_returns_a_new_vertex) {
+  Vertex *a = graph_initialize('a');
+
+  assert_that(a, is_not_equal_to(NULL));
+}
+
 TestSuite *graph_tests() {
   TestSuite *x = create_test_suite();