From d73a90e6b0dbe350f035e68e2c4fe2925bed36c8 Mon Sep 17 00:00:00 2001 From: KRUGSON Date: Sun, 5 Feb 2023 03:20:57 +0100 Subject: [PATCH] added nav_helper with test --- src/c/nav_helper.c | 12 ++++++++++++ src/c/nav_helper.h | 9 +++++++++ test/c/test_nav_helper.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 src/c/nav_helper.c create mode 100644 src/c/nav_helper.h create mode 100644 test/c/test_nav_helper.c diff --git a/src/c/nav_helper.c b/src/c/nav_helper.c new file mode 100644 index 0000000..e36961d --- /dev/null +++ b/src/c/nav_helper.c @@ -0,0 +1,12 @@ +//bibs +#include + +//headers +#include "nav_helper.h" + +bool startsWith(const char *a, const char *b) +{ + if (strncmp(a, b, strlen(b)) == 0) + return 1; + return 0; +}; \ No newline at end of file diff --git a/src/c/nav_helper.h b/src/c/nav_helper.h new file mode 100644 index 0000000..9e513d2 --- /dev/null +++ b/src/c/nav_helper.h @@ -0,0 +1,9 @@ +#ifndef NAV_HELPER_H +#define NAV_HELPER_H + +#include +#include + +bool startsWith(const char *a, const char *b); + +#endif \ No newline at end of file diff --git a/test/c/test_nav_helper.c b/test/c/test_nav_helper.c new file mode 100644 index 0000000..cbf1d42 --- /dev/null +++ b/test/c/test_nav_helper.c @@ -0,0 +1,36 @@ +#ifdef TEST + +#include "unity.h" +#include "nav_helper.h" + +void setUp(void) +{ +} + +void tearDown(void) +{ +} + +void test_nav_helper(void) +{ + /* arrange */ + // Hier die Werte eingeben + char* stringToCheckIsTrue = "#test"; + char* stringToCheckIsFalse = "test"; + + /* act */ + // Die Funktion wird ausgeführt + bool valueIsTrue = startsWith(stringToCheckIsTrue,"#"); + bool valueIsFalse = startsWith(stringToCheckIsFalse, "#"); + + //Output + printf("%s startet mit '#' = %d\n",stringToCheckIsTrue, valueIsTrue); + printf("%s startet mit '#' = %d",stringToCheckIsFalse, valueIsFalse); + + /* assert */ + // Vergleichen mit Inhalt + TEST_ASSERT_TRUE(valueIsTrue); + TEST_ASSERT_FALSE(valueIsFalse); +} + +#endif // TEST \ No newline at end of file