add errors to severity functions #455
Labels
enhancement
new features or improvements
good first issue
something that would be simple for a newcomer to stumpless to work on
help wanted
external contributations encouraged
The functions dealing with severities do not currently properly handle error codes. They should generate appropriate error messages when a failure occurs, so that users checking for errors are properly notified. Additionally, errors should be cleared in the event of success so that an error is not mistakenly identified for a successful call. The affected functions are:
stumpless_get_severity_string
stumpless_get_severity_enum
stumpless_get_severity_enum_from_buffer
General Approach
There are a few details left out of the following approach, for you to fill in as you encounter them. If you find you need help, please ask here or on the project gitter and someone can help you get past the stumbling block.
Add your new tests to the test suite for the severity functions
test/function/severity.cpp
. Each function should have a new test for error clearing, and the existing tests should be enhanced.The new tests will cause a failure by misusing a different function in order to purposefully generate an error.
stumpless_version_to_string
is a simple function to misuse (pass it a NULL arg) as one candidate. Assert that there is in fact an error withEXPECT_ERROR_ID_EQ
. It will then call the severity function normally, check the result, and ensure that no error is raised withEXPECT_NO_ERROR
. Look to other tests for usage of these expect macros. Ensure that the new tests fail, and then add calls toclear_error
in the functions themselves to fix the issue.For existing tests, add calls to
EXPECT_ERROR_ID_EQ
withSTUMPLESS_INVALID_SEVERITY
as the expected error. Update the functions themselves to raise this error upon failure, and update the documentation to reflect this behavior.The text was updated successfully, but these errors were encountered: