diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2016-09-03 19:57:54 +0200 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2016-09-03 20:28:55 +0200 |
commit | 74ca21a41bcb5a49d19e65c9ba88f1f864cb7095 (patch) | |
tree | 4774587e47abc0ff20453abbf714b63c36697f26 /tests/check_error.c | |
parent | 30ae5fd4f65f48009e6956e42ccc2c9d9ad80901 (diff) | |
download | blogc-74ca21a41bcb5a49d19e65c9ba88f1f864cb7095.tar.gz blogc-74ca21a41bcb5a49d19e65c9ba88f1f864cb7095.tar.bz2 blogc-74ca21a41bcb5a49d19e65c9ba88f1f864cb7095.zip |
*: big code reorganization.
- source and tests are now splitted by target
- utils lib is now called common
still pending move error.c from blogc to common
Diffstat (limited to 'tests/check_error.c')
-rw-r--r-- | tests/check_error.c | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/tests/check_error.c b/tests/check_error.c deleted file mode 100644 index e844998..0000000 --- a/tests/check_error.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * blogc: A blog compiler. - * Copyright (C) 2015-2016 Rafael G. Martins <rafael@rafaelmartins.eng.br> - * - * This program can be distributed under the terms of the BSD License. - * See the file LICENSE. - */ - -#include <stdarg.h> -#include <stddef.h> -#include <setjmp.h> -#include <cmocka.h> -#include <string.h> -#include "../src/error.h" - - -static void -test_error_new(void **state) -{ - blogc_error_t *error = blogc_error_new(1, "bola %s"); - assert_non_null(error); - assert_int_equal(error->type, 1); - assert_string_equal(error->msg, "bola %s"); - blogc_error_free(error); -} - - -static void -test_error_new_printf(void **state) -{ - blogc_error_t *error = blogc_error_new_printf(2, "bola %s", "guda"); - assert_non_null(error); - assert_int_equal(error->type, 2); - assert_string_equal(error->msg, "bola guda"); - blogc_error_free(error); -} - - -static void -test_error_parser(void **state) -{ - const char *a = "bola\nguda\nchunda\n"; - blogc_error_t *error = blogc_error_parser(1, a, strlen(a), 11, "asd %d", 10); - assert_non_null(error); - assert_int_equal(error->type, 1); - assert_string_equal(error->msg, - "asd 10\nError occurred near line 3, position 2: chunda"); - blogc_error_free(error); - a = "bola\nguda\nchunda"; - error = blogc_error_parser(1, a, strlen(a), 11, "asd %d", 10); - assert_non_null(error); - assert_int_equal(error->type, 1); - assert_string_equal(error->msg, - "asd 10\nError occurred near line 3, position 2: chunda"); - blogc_error_free(error); - a = "bola\nguda\nchunda"; - error = blogc_error_parser(1, a, strlen(a), 0, "asd %d", 10); - assert_non_null(error); - assert_int_equal(error->type, 1); - assert_string_equal(error->msg, - "asd 10\nError occurred near line 1, position 1: bola"); - blogc_error_free(error); - a = ""; - error = blogc_error_parser(1, a, strlen(a), 0, "asd %d", 10); - assert_non_null(error); - assert_int_equal(error->type, 1); - assert_string_equal(error->msg, "asd 10"); - blogc_error_free(error); -} - - -static void -test_error_parser_crlf(void **state) -{ - const char *a = "bola\r\nguda\r\nchunda\r\n"; - blogc_error_t *error = blogc_error_parser(1, a, strlen(a), 13, "asd %d", 10); - assert_non_null(error); - assert_int_equal(error->type, 1); - assert_string_equal(error->msg, - "asd 10\nError occurred near line 3, position 2: chunda"); - blogc_error_free(error); - a = "bola\r\nguda\r\nchunda"; - error = blogc_error_parser(1, a, strlen(a), 13, "asd %d", 10); - assert_non_null(error); - assert_int_equal(error->type, 1); - assert_string_equal(error->msg, - "asd 10\nError occurred near line 3, position 2: chunda"); - blogc_error_free(error); - a = "bola\r\nguda\r\nchunda"; - error = blogc_error_parser(1, a, strlen(a), 0, "asd %d", 10); - assert_non_null(error); - assert_int_equal(error->type, 1); - assert_string_equal(error->msg, - "asd 10\nError occurred near line 1, position 1: bola"); - blogc_error_free(error); -} - - -int -main(void) -{ - const UnitTest tests[] = { - unit_test(test_error_new), - unit_test(test_error_new_printf), - unit_test(test_error_parser), - unit_test(test_error_parser_crlf), - }; - return run_tests(tests); -} |