A character assumption/assertion focuses on verifying individual characters in a string or data stream. This assumption ensures that characters meet specific criteria, such as being alphanumeric, a specific character set, or within a defined range. It’s particularly useful in scenarios where input needs to be validated at the character level, such as parsing or processing text and ensuring no invalid characters are present.
Code reference for C, C++, or Python APIs for a respective Fossil Logic Project.
C, C++ REFERENCE #
/**
* @brief Assumes that the given char values are equal.
*
* @param actual The actual char value.
* @param expected The expected char value.
*/
#define ASSUME_ITS_EQUAL_CHAR(actual, expected) \
FOSSIL_TEST_ASSUME((char)(actual) == (char)(expected), "Expected char " #actual " to be equal to " #expected)
/**
* @brief Assumes that the given char values are not equal.
*
* @param actual The actual char value.
* @param expected The expected char value.
*/
#define ASSUME_NOT_EQUAL_CHAR(actual, expected) \
FOSSIL_TEST_ASSUME((char)(actual) != (char)(expected), "Expected char " #actual " to not be equal to " #expected)
/**
* @brief Assumes that the given char value is less than the expected value.
*
* @param actual The actual char value.
* @param expected The expected char value.
*/
#define ASSUME_ITS_LESS_THAN_CHAR(actual, expected) \
FOSSIL_TEST_ASSUME((char)(actual) < (char)(expected), "Expected char " #actual " to be less than " #expected)
/**
* @brief Assumes that the given char value is more than the expected value.
*
* @param actual The actual char value.
* @param expected The expected char value.
*/
#define ASSUME_ITS_MORE_THAN_CHAR(actual, expected) \
FOSSIL_TEST_ASSUME((char)(actual) > (char)(expected), "Expected char " #actual " to be more than " #expected)
/**
* @brief Assumes that the given char value is less than or equal to the expected value.
*
* @param actual The actual char value.
* @param expected The expected char value.
*/
#define ASSUME_ITS_LESS_OR_EQUAL_CHAR(actual, expected) \
FOSSIL_TEST_ASSUME((char)(actual) <= (char)(expected), "Expected char " #actual " to be less than or equal to " #expected)
/**
* @brief Assumes that the given char value is more than or equal to the expected value.
*
* @param actual The actual char value.
* @param expected The expected char value.
*/
#define ASSUME_ITS_MORE_OR_EQUAL_CHAR(actual, expected) \
FOSSIL_TEST_ASSUME((char)(actual) >= (char)(expected), "Expected char " #actual " to be more than or equal to " #expected)
/**
* @brief Assumes that the given char value is not less than the expected value.
*
* @param actual The actual char value.
* @param expected The expected char value.
*/
#define ASSUME_NOT_LESS_THAN_CHAR(actual, expected) \
FOSSIL_TEST_ASSUME((char)(actual) >= (char)(expected), "Expected char " #actual " to not be less than " #expected)
/**
* @brief Assumes that the given char value is not more than the expected value.
*
* @param actual The actual char value.
* @param expected The expected char value.
*/
#define ASSUME_NOT_MORE_THAN_CHAR(actual, expected) \
FOSSIL_TEST_ASSUME((char)(actual) <= (char)(expected), "Expected char " #actual " to not be more than " #expected)
/**
* @brief Assumes that the given char value is not less than or equal to the expected value.
*
* @param actual The actual char value.
* @param expected The expected char value.
*/
#define ASSUME_NOT_LESS_OR_EQUAL_CHAR(actual, expected) \
FOSSIL_TEST_ASSUME((char)(actual) > (char)(expected), "Expected char " #actual " to not be less than or equal to " #expected)
/**
* @brief Assumes that the given char value is not more than or equal to the expected value.
*
* @param actual The actual char value.
* @param expected The expected char value.
*/
#define ASSUME_NOT_MORE_OR_EQUAL_CHAR(actual, expected) \
FOSSIL_TEST_ASSUME((char)(actual) < (char)(expected), "Expected char " #actual " to not be more than or equal to " #expected)PYTHON REFERENCE #
# TODO: add code here