mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-05-20 17:07:32 +08:00
Add support for TEST_RANGE with exclusive end
If the range is <start, end, step> instead of [start, end, step], the end value will not be included in the range. This can be useful if you have a define that defines e.g. the size of something and you want to use this define as the end value. As the pre-processor doesn't evalutate expressions (unless you do some macro magic) you can't specify the range as [0, MY_SIZE - 1, 1]. With this change you can then instead give the range <0, MY_SIZE, 1>.
This commit is contained in:
@ -173,6 +173,32 @@ void test_CharsArePreserved(unsigned index, char c)
|
||||
NextExpectedCharIndex++;
|
||||
}
|
||||
|
||||
TEST_RANGE([0, 10, 2])
|
||||
void test_SingleRange(unsigned value)
|
||||
{
|
||||
TEST_ASSERT_EQUAL(0, value % 2);
|
||||
TEST_ASSERT_LESS_OR_EQUAL(10, value);
|
||||
}
|
||||
|
||||
TEST_RANGE([1, 2, 1], [2, 1, -1])
|
||||
void test_TwoRanges(unsigned first, unsigned second)
|
||||
{
|
||||
TEST_ASSERT_LESS_OR_EQUAL(4, first * second);
|
||||
}
|
||||
|
||||
TEST_RANGE(<0, 10, 2>)
|
||||
void test_SingleExclusiveRange(unsigned value)
|
||||
{
|
||||
TEST_ASSERT_EQUAL(0, value % 2);
|
||||
TEST_ASSERT_LESS_THAN(10, value);
|
||||
}
|
||||
|
||||
TEST_RANGE([2, 4, 1], <1, 2, 1>)
|
||||
void test_BothInclusiveAndExclusiveRange(unsigned first, unsigned second)
|
||||
{
|
||||
TEST_ASSERT_LESS_THAN(first, second);
|
||||
}
|
||||
|
||||
TEST_CASE(0,
|
||||
|
||||
1)
|
||||
|
Reference in New Issue
Block a user