From 8737272f80feb3d3c477e984568790008f2d6bc0 Mon Sep 17 00:00:00 2001 From: mo khan Date: Mon, 7 Sep 2020 13:55:54 -0600 Subject: feat: add function to init vertex --- src/03/graph.c | 7 +++++++ src/03/graph.h | 5 +++++ src/03/graph_test.c | 6 ++++++ 3 files changed, 18 insertions(+) (limited to 'src') diff --git a/src/03/graph.c b/src/03/graph.c index e8b6b5e..ed244ba 100644 --- a/src/03/graph.c +++ b/src/03/graph.c @@ -1 +1,8 @@ #include "graph.h" +#include + +Vertex *graph_initialize(char label) { + Vertex *item = malloc(sizeof(Vertex)); + item->label = label; + return item; +}; diff --git a/src/03/graph.h b/src/03/graph.h index e69de29..26fb7c6 100644 --- a/src/03/graph.h +++ b/src/03/graph.h @@ -0,0 +1,5 @@ +typedef struct { + char label; +} Vertex; + +Vertex *graph_initialize(char label); diff --git a/src/03/graph_test.c b/src/03/graph_test.c index fca7b45..ecc47bb 100644 --- a/src/03/graph_test.c +++ b/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(); -- cgit v1.2.3