[A] Add ft_strerror function

This commit is contained in:
seleznevae
2020-02-08 12:15:35 +03:00
parent bff48549de
commit 58a63f90f2
9 changed files with 137 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ add_executable(${PROJECT_NAME}_test_dev
bb_tests/test_table_border_style.c
bb_tests/test_table_properties.c
bb_tests/test_memory_errors.c
bb_tests/test_error_codes.c
tests.c
test_utils.c)
target_link_libraries(${PROJECT_NAME}_test_dev
@@ -30,6 +31,7 @@ add_executable(${PROJECT_NAME}_test
bb_tests/test_table_border_style.c
bb_tests/test_table_properties.c
bb_tests/test_memory_errors.c
bb_tests/test_error_codes.c
tests.c
test_utils.c)
target_link_libraries(${PROJECT_NAME}_test

View File

@@ -0,0 +1,27 @@
#include "tests.h"
#include "fort.h"
void test_error_codes(void)
{
// Nonnegative code is success
{
assert_str_equal(ft_strerror(0), "Libfort success");
assert_str_equal(ft_strerror(1), "Libfort success");
assert_str_equal(ft_strerror(2), "Libfort success");
assert_str_equal(ft_strerror(42), "Libfort success");
assert_str_equal(ft_strerror(INT_MAX), "Libfort success");
}
// Error codes
{
assert_str_equal(ft_strerror(FT_MEMORY_ERROR), "Libfort error (out of memory)");
assert_str_equal(ft_strerror(FT_ERROR), "Libfort error (general error)");
assert_str_equal(ft_strerror(FT_EINVAL), "Libfort error (invalid argument)");
assert_str_equal(ft_strerror(FT_INTERN_ERROR), "Libfort error (internal logic error)");
assert_str_equal(ft_strerror(-42), "Libfort unknown error");
assert_str_equal(ft_strerror(-666), "Libfort unknown error");
assert_str_equal(ft_strerror(-INT_MAX), "Libfort unknown error");
}
}

View File

@@ -24,6 +24,7 @@ void test_table_cell_properties(void);
void test_table_text_styles(void);
void test_table_tbl_properties(void);
void test_memory_errors(void);
void test_error_codes(void);
#ifdef FT_HAVE_UTF8
void test_utf8_table(void);
#endif
@@ -60,6 +61,7 @@ struct test_case bb_test_suite [] = {
{"test_table_tbl_properties", test_table_tbl_properties},
{"test_table_text_styles", test_table_text_styles},
{"test_memory_errors", test_memory_errors},
{"test_error_codes", test_error_codes},
};
#ifdef FORT_WB_TESTING_ENABLED