[A] Add ft_strerror function
This commit is contained in:
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");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user