[A] Add ft_strerror function
This commit is contained in:
@@ -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
|
||||
|
27
tests/bb_tests/test_error_codes.c
Normal file
27
tests/bb_tests/test_error_codes.c
Normal 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");
|
||||
}
|
||||
}
|
@@ -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
|
||||
|
Reference in New Issue
Block a user