diff --git a/src/Makefile.am b/src/Makefile.am index 24c27a7..0dad66f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -38,7 +38,7 @@ testsuite_SOURCES = ../tests/unit/lexer/lexer_tests.c \ ../tests/unit/utils/utils_tests.c \ ../tests/unit/expansion/expand.c \ ../tests/unit/expansion/parse_var.c \ - #../tests/unit/io_backend/io_backend.c \ + ../tests/unit/io_backend/io_backend.c \ ../tests/unit/utils/args.c \ ../tests/unit/utils/hash_map.c \ ../tests/unit/utils/insert_into.c diff --git a/tests/unit/io_backend/io_backend.c b/tests/unit/io_backend/io_backend.c index 47e02db..1fa9dfa 100644 --- a/tests/unit/io_backend/io_backend.c +++ b/tests/unit/io_backend/io_backend.c @@ -11,10 +11,10 @@ Test(IO_Backend, init_null) { struct iob_context ctx = { - .iob_mode = IOB_MODE_NULL; - .args = NULL; -}; -int actual = iob_init(ctx); + .mode = IOB_MODE_NULL, + .args = NULL + }; + int actual = iob_init(&ctx); int expected = IOB_ERROR_BAD_ARG; cr_expect(actual == expected, "Expected: %d. Got: %d", expected, actual); } @@ -23,10 +23,10 @@ Test(IO_Backend, init_stdin) { struct iob_context ctx = { - .iob_mode = IOB_MODE_STDIN; - .args = NULL; -}; -int actual = iob_init(ctx); + .mode = IOB_MODE_STDIN, + .args = NULL + }; + int actual = iob_init(&ctx); int expected = 0; cr_expect(actual == expected, "Expected: %d. Got: %d", expected, actual); iob_close(); @@ -36,15 +36,16 @@ iob_close(); // Same applies for other tests Test(IO_Backend, init_script) { - char *script_name = "script.tmp" struct iob_context ctx = { - .iob_mode = IOB_MODE_SCRIPT; - .args = script_name; -}; -// Create file -FILE *f = fopen(script_name, "w"); -fclose(f); + char *script_name = "script.tmp"; + struct iob_context ctx = { + .mode = IOB_MODE_SCRIPT, + .args = script_name + }; + // Create file + FILE *f = fopen(script_name, "w"); + fclose(f); -int actual = iob_init(ctx); + int actual = iob_init(&ctx); int expected = 0; cr_expect(actual == expected, "Expected: %d. Got: %d", expected, actual); iob_close(); @@ -53,11 +54,12 @@ remove(script_name); Test(IO_Backend, init_script_not_a_file) { - char *script_name = "not_a_file.tmp" struct iob_context ctx = { - .iob_mode = IOB_MODE_SCRIPT; - .args = script_name; -}; -int actual = iob_init(ctx); + char *script_name = "not_a_file.tmp"; + struct iob_context ctx = { + .mode = IOB_MODE_SCRIPT, + .args = script_name + }; + int actual = iob_init(&ctx); int expected = IOB_ERROR_CANNOT_OPEN_FILE; cr_expect(actual == expected, "Expected: %d. Got: %d", expected, actual); } @@ -66,21 +68,22 @@ Test(IO_Backend, init_script_null) { struct iob_context ctx = { - .iob_mode = IOB_MODE_SCRIPT; - .args = NULL; -}; -int actual = iob_init(ctx); + .mode = IOB_MODE_SCRIPT, + .args = NULL + }; + int actual = iob_init(&ctx); int expected = IOB_ERROR_CANNOT_OPEN_FILE; cr_expect(actual == expected, "Expected: %d. Got: %d", expected, actual); } Test(IO_Backend, init_cmd) { - char *cmd = "iamacommand --yesido" struct iob_context ctx = { - .iob_mode = IOB_MODE_CMD; - .args = cmd; -}; -int actual = iob_init(ctx); + char *cmd = "iamacommand --yesido"; + struct iob_context ctx = { + .mode = IOB_MODE_CMD, + .args = cmd + }; + int actual = iob_init(&ctx); int expected = 0; cr_expect(actual == expected, "Expected: %d. Got: %d", expected, actual); iob_close(); @@ -90,23 +93,24 @@ Test(IO_Backend, init_cmd_null) { struct iob_context ctx = { - .iob_mode = IOB_MODE_CMD; - .args = NULL; -}; -int actual = iob_init(ctx); + .mode = IOB_MODE_CMD, + .args = NULL + }; + int actual = iob_init(&ctx); int expected = IOB_ERROR_BAD_ARG; cr_expect(actual == expected, "Expected: %d. Got: %d", expected, actual); } Test(IO_Backend, init_already_init) { - char *cmd = "iamacommand --yesido" struct iob_context ctx = { - .iob_mode = IOB_MODE_CMD; - .args = cmd; -}; -iob_init(ctx); -int actual = iob_init(ctx); -int expected = IOB_ERROR_ALREADY_INITIALIZED; + char *cmd = "iamacommand --yesido"; + struct iob_context ctx = { + .mode = IOB_MODE_CMD, + .args = cmd + }; + iob_init(&ctx); + int actual = iob_init(&ctx); + int expected = IOB_ERROR_MODULE_ALREADY_INITIALIZED; cr_expect(actual == expected, "Expected: %d. Got: %d", expected, actual); iob_close(); }