diff --git a/P02_QR_Code_auf_Terminal/P02_QR_Code_auf_Terminal.pdf b/P02_QR_Code_auf_Terminal/P02_QR_Code_auf_Terminal.pdf index 4e1f04e..20b59f8 100644 Binary files a/P02_QR_Code_auf_Terminal/P02_QR_Code_auf_Terminal.pdf and b/P02_QR_Code_auf_Terminal/P02_QR_Code_auf_Terminal.pdf differ diff --git a/P02_QR_Code_auf_Terminal/bit-manipulation/Makefile b/P02_QR_Code_auf_Terminal/bit-manipulation/Makefile deleted file mode 100644 index 50ddb7a..0000000 --- a/P02_QR_Code_auf_Terminal/bit-manipulation/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -SNP_SHARED_MAKEFILE := $(if $(SNP_SHARED_MAKEFILE),$(SNP_SHARED_MAKEFILE),"~/snp/shared.mk") - -TARGET := bin/bit-manipulation -SOURCES := src/main.c -TSTSOURCES := tests/tests.c - -include $(SNP_SHARED_MAKEFILE) diff --git a/P02_QR_Code_auf_Terminal/bit-manipulation/mainpage.dox b/P02_QR_Code_auf_Terminal/bit-manipulation/mainpage.dox deleted file mode 100644 index 2611637..0000000 --- a/P02_QR_Code_auf_Terminal/bit-manipulation/mainpage.dox +++ /dev/null @@ -1,8 +0,0 @@ -/** - * @mainpage SNP - P02 QR Code - * - * @section Purpose - * - * This is a lab to display a QR code on the color terminal. - * - */ diff --git a/P02_QR_Code_auf_Terminal/bit-manipulation/src/main.c b/P02_QR_Code_auf_Terminal/bit-manipulation/src/main.c deleted file mode 100644 index bd0a4ef..0000000 --- a/P02_QR_Code_auf_Terminal/bit-manipulation/src/main.c +++ /dev/null @@ -1,53 +0,0 @@ -/* ---------------------------------------------------------------------------- - * -- _____ ______ _____ - - * -- |_ _| | ____|/ ____| - - * -- | | _ __ | |__ | (___ Institute of Embedded Systems - - * -- | | | '_ \| __| \___ \ Zuercher Hochschule Winterthur - - * -- _| |_| | | | |____ ____) | (University of Applied Sciences) - - * -- |_____|_| |_|______|_____/ 8401 Winterthur, Switzerland - - * ---------------------------------------------------------------------------- - */ -/** - * @file - * @brief Lab P02 bit Manipulation - */ -#include -#include -#include - -#define USAGE "usage: %s value [bitnr]\n value in the range 0..255\n bitnr in the range 0..7\n" - -/** - * @brief main function - * @returns always success (0) - */ -int main(int argc, const char* argv[]) -{ - // check arguments and get the values - // BEGIN-STUDENTS-TO-ADD-CODE - - - - - - // END-STUDENTS-TO-ADD-CODE - - if (argc == 2) { - // BEGIN-STUDENTS-TO-ADD-CODE - - - - - // END-STUDENTS-TO-ADD-CODE - } else { - // BEGIN-STUDENTS-TO-ADD-CODE - - - - - - // END-STUDENTS-TO-ADD-CODE - } - - return EXIT_SUCCESS; -} diff --git a/P02_QR_Code_auf_Terminal/bit-manipulation/tests/tests.c b/P02_QR_Code_auf_Terminal/bit-manipulation/tests/tests.c deleted file mode 100644 index 89c09ed..0000000 --- a/P02_QR_Code_auf_Terminal/bit-manipulation/tests/tests.c +++ /dev/null @@ -1,174 +0,0 @@ -/* ---------------------------------------------------------------------------- - * -- _____ ______ _____ - - * -- |_ _| | ____|/ ____| - - * -- | | _ __ | |__ | (___ 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 "test_utils.h" - -#ifndef TARGET // must be given by the make file --> see test target -#error missing TARGET define -#endif - -/// @brief The name of the STDOUT text file. -#define OUTFILE "stdout.txt" -/// @brief The name of the STDERR text file. -#define ERRFILE "stderr.txt" -/// @brief The input data -#define SNP_INPUT "snp.input" - -// 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_no_arg(void) -{ - // arrange - - // act - int exit_code = system(XSTR(TARGET) " 1>/dev/null 2>/dev/null"); - // assert - CU_ASSERT_EQUAL(WEXITSTATUS(exit_code), EXIT_FAILURE); - -} - -static void test_13(void) -{ - // arrange - const char *out_txt[] = - { "unsigned: 13 (0x0d)\n" - , " signed: 13 (0x0d)\n" - , " +255: 12 (0x0c)\n" - , " one's: -14 (0xfffffff2)\n" - , " two's: -13 (0xfffffff3)\n" - }; - const char *err_txt[] = { NULL }; - // act - int exit_code = system(XSTR(TARGET) " 13 1>" OUTFILE " 2>" ERRFILE); - // assert - CU_ASSERT_EQUAL(WEXITSTATUS(exit_code), EXIT_SUCCESS); - assert_lines(OUTFILE, out_txt, sizeof(out_txt)/sizeof(*out_txt)); - assert_lines(ERRFILE, err_txt, sizeof(err_txt)/sizeof(*err_txt)); -} - -static void test_131_2(void) -{ - // arrange - const char *out_txt[] = - { " dec hex oct\n" - , "your input : 131 0x83 0203\n" - , "bit 2 is not set.\n" - , "bit 2 cleared: 131 0x83 0203\n" - , "bit 2 set : 135 0x87 0207\n" - , "bit 2 flipped: 135 0x87 0207\n" - }; - const char *err_txt[] = { NULL }; - // act - int exit_code = system(XSTR(TARGET) " 131 2 1>" OUTFILE " 2>" ERRFILE); - // assert - CU_ASSERT_EQUAL(WEXITSTATUS(exit_code), EXIT_SUCCESS); - assert_lines(OUTFILE, out_txt, sizeof(out_txt)/sizeof(*out_txt)); - assert_lines(ERRFILE, err_txt, sizeof(err_txt)/sizeof(*err_txt)); -} - -static void test_255_7(void) -{ - // arrange - const char *out_txt[] = - { " dec hex oct\n" - , "your input : 255 0xff 0377\n" - , "bit 7 is set.\n" - , "bit 7 cleared: 127 0x7f 0177\n" - , "bit 7 set : 255 0xff 0377\n" - , "bit 7 flipped: 127 0x7f 0177\n" - }; - const char *err_txt[] = { NULL }; - // act - int exit_code = system(XSTR(TARGET) " 255 7 1>" OUTFILE " 2>" ERRFILE); - // assert - CU_ASSERT_EQUAL(WEXITSTATUS(exit_code), EXIT_SUCCESS); - assert_lines(OUTFILE, out_txt, sizeof(out_txt)/sizeof(*out_txt)); - assert_lines(ERRFILE, err_txt, sizeof(err_txt)/sizeof(*err_txt)); -} - -static void test_127_7(void) -{ - // arrange - const char *out_txt[] = - { " dec hex oct\n" - , "your input : 127 0x7f 0177\n" - , "bit 7 is not set.\n" - , "bit 7 cleared: 127 0x7f 0177\n" - , "bit 7 set : 255 0xff 0377\n" - , "bit 7 flipped: 255 0xff 0377\n" - }; - const char *err_txt[] = { NULL }; - // act - int exit_code = system(XSTR(TARGET) " 127 7 1>" OUTFILE " 2>" ERRFILE); - // assert - CU_ASSERT_EQUAL(WEXITSTATUS(exit_code), EXIT_SUCCESS); - assert_lines(OUTFILE, out_txt, sizeof(out_txt)/sizeof(*out_txt)); - assert_lines(ERRFILE, err_txt, sizeof(err_txt)/sizeof(*err_txt)); -} - -static void test_0_0(void) -{ - // arrange - const char *out_txt[] = - { " dec hex oct\n" - , "your input : 0 0x00 0000\n" - , "bit 0 is not set.\n" - , "bit 0 cleared: 0 0x00 0000\n" - , "bit 0 set : 1 0x01 0001\n" - , "bit 0 flipped: 1 0x01 0001\n" - }; - const char *err_txt[] = { NULL }; - // act - int exit_code = system(XSTR(TARGET) " 0 0 1>" OUTFILE " 2>" ERRFILE); - // assert - CU_ASSERT_EQUAL(WEXITSTATUS(exit_code), EXIT_SUCCESS); - assert_lines(OUTFILE, out_txt, sizeof(out_txt)/sizeof(*out_txt)); - assert_lines(ERRFILE, err_txt, sizeof(err_txt)/sizeof(*err_txt)); -} - -/** - * @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_no_arg - , test_13 - , test_131_2 - , test_255_7 - , test_127_7 - , test_0_0 - ); - -}