2021-05-05, 09:44 AM
2021-05-05: y_testing Assertions
When writing tests with y_testing, most checks use ASSERT:
It?s simple and clear.? However, if x isn?t 2 it doesn?t give you much information - all that?s known is that some boolean check was false.? For most common operations there are more specific tests that give you far more useful information.? In all these assertions, if they fail, the failed test and the value of testee are printed to help with debugging.
When writing tests with y_testing, most checks use ASSERT:
Quote:
ASSERT(x == 2);
It?s simple and clear.? However, if x isn?t 2 it doesn?t give you much information - all that?s known is that some boolean check was false.? For most common operations there are more specific tests that give you far more useful information.? In all these assertions, if they fail, the failed test and the value of testee are printed to help with debugging.
- ASSERT_EQ(testee, comparison) - Checks if the testee value equals the given constant comparison.
- ASSERT_NE(testee, comparison) - Checks if the testee value doesn?t equal the given constant comparison.
- ASSERT_LE(testee, comparison) - Checks if the testee value is less than or equal to the given constant comparison.
- ASSERT_LT(testee, comparison) - Checks if the testee value is less than the given constant comparison.
- ASSERT_GE(testee, comparison) - Checks if the testee value is greater than or equal to the given constant comparison.
- ASSERT_GT(testee, comparison) - Checks if the testee value is greater than the given constant comparison.
- ASSERT_ZE(testee) - Checks if the testee value is zero.
- ASSERT_NZ(testee) - Checks if the testee value is not zero.
- ASSERT_SAME(testee, string) - Checks if testee is the given string.
- ASSERT_DIFF(testee, string) - Checks if testee is not the given string.
- ASSERT_NEAR(testee, string) - Checks if testee is the given string, ignoring case.