Skip to content

Commit f1ca39a

Browse files
committed
bsdtest harness: Test for bad uint32 values
Adding testing functions to verify that a uint32 isn't a specific number.
1 parent 0bad089 commit f1ca39a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

tests/bsdtests.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,20 @@ test_uint32_format(uint32_t actual, uint32_t expected, const char *format, ...)
164164
_test_uint32(NULL, 0, desc, actual, expected);
165165
}
166166

167+
void
168+
_test_uint32_not(const char* file, long line, const char* desc, uint32_t actual, uint32_t unexpected)
169+
{
170+
_test_print(file, line, desc,
171+
(actual != unexpected), "%u", actual, "!%u", unexpected);
172+
}
173+
174+
void
175+
test_uint32_not_format(uint32_t actual, uint32_t unexpected, const char *format, ...)
176+
{
177+
GENERATE_DESC
178+
_test_uint32_not(NULL, 0, desc, actual, unexpected);
179+
}
180+
167181
void
168182
_test_int32(const char* file, long line, const char* desc, int32_t actual, int32_t expected)
169183
{

tests/bsdtests.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ void _test_uint32(const char* file, long line, const char* desc, uint32_t actual
111111
#define test_uint32(a,b,c) _test_uint32(__SOURCE_FILE__, __LINE__, a, b, c)
112112
void test_uint32_format(uint32_t actual, uint32_t expected, const char *format, ...) __printflike(3,4);
113113

114+
void _test_uint32_not(const char* file, long line, const char* desc, uint32_t actual, uint32_t unexpected);
115+
#define test_uint32_not(a,b,c) _test_uint32(__SOURCE_FILE__, __LINE__, a, b, c)
116+
void test_uint32_not_format(uint32_t actual, uint32_t unexpected, const char *format, ...) __printflike(3,4);
117+
114118
void _test_int32(const char* file, long line, const char* desc, int32_t actual, int32_t expected);
115119
#define test_int32(a,b,c) _test_int32(__SOURCE_FILE__, __LINE__, a, b, c)
116120
void test_int32_format(int32_t actual, int32_t expected, const char* format, ...) __printflike(3,4);

0 commit comments

Comments
 (0)