From 94945069e344906c621f30821dbdffd63f92ade0 Mon Sep 17 00:00:00 2001 From: Andreas Gieriet Date: Sun, 5 Apr 2020 23:07:39 +0200 Subject: [PATCH] P07 lab code added --- .../personen-verwaltung/Makefile | 13 ++ .../personen-verwaltung/mainpage.dox | 8 ++ .../personen-verwaltung/src/main.c | 29 +++++ .../personen-verwaltung/tests/tests.c | 119 ++++++++++++++++++ 4 files changed, 169 insertions(+) create mode 100644 P07_Personen_Verwaltung_Linked_List/personen-verwaltung/Makefile create mode 100644 P07_Personen_Verwaltung_Linked_List/personen-verwaltung/mainpage.dox create mode 100644 P07_Personen_Verwaltung_Linked_List/personen-verwaltung/src/main.c create mode 100644 P07_Personen_Verwaltung_Linked_List/personen-verwaltung/tests/tests.c diff --git a/P07_Personen_Verwaltung_Linked_List/personen-verwaltung/Makefile b/P07_Personen_Verwaltung_Linked_List/personen-verwaltung/Makefile new file mode 100644 index 0000000..44f82b3 --- /dev/null +++ b/P07_Personen_Verwaltung_Linked_List/personen-verwaltung/Makefile @@ -0,0 +1,13 @@ +SNP_SHARED_MAKEFILE := $(if $(SNP_SHARED_MAKEFILE),$(SNP_SHARED_MAKEFILE),"~/snp/shared.mk") + +TARGET := bin/personen-verwaltung +# BEGIN-STUDENTS-TO-ADD-CODE +MODULES := +# END-STUDENTS-TO-ADD-CODE +SOURCES := src/main.c $(MODULES) +TSTSOURCES := tests/tests.c $(MODULES) + + +include $(SNP_SHARED_MAKEFILE) + +# CFLAGS += -Werror diff --git a/P07_Personen_Verwaltung_Linked_List/personen-verwaltung/mainpage.dox b/P07_Personen_Verwaltung_Linked_List/personen-verwaltung/mainpage.dox new file mode 100644 index 0000000..05d1c72 --- /dev/null +++ b/P07_Personen_Verwaltung_Linked_List/personen-verwaltung/mainpage.dox @@ -0,0 +1,8 @@ +/** + * @mainpage SNP - P07 Linked List + * + * @section Purpose + * + * This is a lab on usage of arrays. + * + */ diff --git a/P07_Personen_Verwaltung_Linked_List/personen-verwaltung/src/main.c b/P07_Personen_Verwaltung_Linked_List/personen-verwaltung/src/main.c new file mode 100644 index 0000000..3dd772a --- /dev/null +++ b/P07_Personen_Verwaltung_Linked_List/personen-verwaltung/src/main.c @@ -0,0 +1,29 @@ +/* ---------------------------------------------------------------------------- + * -- _____ ______ _____ - + * -- |_ _| | ____|/ ____| - + * -- | | _ __ | |__ | (___ Institute of Embedded Systems - + * -- | | | '_ \| __| \___ \ Zuercher Hochschule Winterthur - + * -- _| |_| | | | |____ ____) | (University of Applied Sciences) - + * -- |_____|_| |_|______|_____/ 8401 Winterthur, Switzerland - + * ---------------------------------------------------------------------------- + */ +/** + * @file + * @brief Lab implementation + */ +#include +#include + +/** + * @brief Main entry point. + * @param[in] argc The size of the argv array. + * @param[in] argv The command line arguments... + * @returns Returns EXIT_SUCCESS (=0) on success, EXIT_FAILURE (=1) there is an expression syntax error. + */ +int main(int argc, char* argv[]) +{ + // BEGIN-STUDENTS-TO-ADD-CODE + + // END-STUDENTS-TO-ADD-CODE + return EXIT_SUCCESS; +} diff --git a/P07_Personen_Verwaltung_Linked_List/personen-verwaltung/tests/tests.c b/P07_Personen_Verwaltung_Linked_List/personen-verwaltung/tests/tests.c new file mode 100644 index 0000000..408182d --- /dev/null +++ b/P07_Personen_Verwaltung_Linked_List/personen-verwaltung/tests/tests.c @@ -0,0 +1,119 @@ +/* ---------------------------------------------------------------------------- + * -- _____ ______ _____ - + * -- |_ _| | ____|/ ____| - + * -- | | _ __ | |__ | (___ Institute of Embedded Systems - + * -- | | | '_ \| __| \___ \ Zuercher Hochschule Winterthur - + * -- _| |_| | | | |____ ____) | (University of Applied Sciences) - + * -- |_____|_| |_|______|_____/ 8401 Winterthur, Switzerland - + * ---------------------------------------------------------------------------- + */ +/** + * @file + * @brief Test suite for the given package. + */ +#include +#include +#include +#include +#include +#include +#include "test_utils.h" + +#ifndef TARGET // must be given by the make file --> see test target +#error missing TARGET define +#endif + +/// @brief alias for EXIT_SUCCESS +#define OK EXIT_SUCCESS +/// @brief alias for EXIT_FAILURE +#define FAIL EXIT_FAILURE + +/// @brief The name of the STDOUT text file. +#define OUTFILE "stdout.txt" +/// @brief The name of the STDERR text file. +#define ERRFILE "stderr.txt" + +#define TRACE_INDENT "\n " ///< allow for better stdout formatting in case of error + +// setup & cleanup +static int setup(void) +{ + remove_file_if_exists(OUTFILE); + remove_file_if_exists(ERRFILE); + return 0; // success +} + +static int teardown(void) +{ + // Do nothing. + // Especially: do not remove result files - they are removed in int setup(void) *before* running a test. + return 0; // success +} + +// tests +static void test_person_compare(void) +{ + // BEGIN-STUDENTS-TO-ADD-CODE + // arrange + + // act + CU_FAIL("missing test"); + + // assert + + // END-STUDENTS-TO-ADD-CODE +} + +static void test_list_insert(void) +{ + // BEGIN-STUDENTS-TO-ADD-CODE + // arrange + + // act + CU_FAIL("missing test"); + + // assert + + // END-STUDENTS-TO-ADD-CODE +} + +static void test_list_remove(void) +{ + // BEGIN-STUDENTS-TO-ADD-CODE + // arrange + + // act + CU_FAIL("missing test"); + + // assert + + // END-STUDENTS-TO-ADD-CODE +} + +static void test_list_clear(void) +{ + // BEGIN-STUDENTS-TO-ADD-CODE + // arrange + + // act + CU_FAIL("missing test"); + + // assert + + // END-STUDENTS-TO-ADD-CODE +} + +/** + * @brief Registers and runs the tests. + * @returns success (0) or one of the CU_ErrorCode (>0) + */ +int main(void) +{ + // setup, run, teardown + TestMainBasic("lab test", setup, teardown + , test_person_compare + , test_list_insert + , test_list_remove + , test_list_clear + ); +}