Commit 955df7d8 authored by Daniel Latypov's avatar Daniel Latypov Committed by Shuah Khan

kunit: reduce layering in string assertion macros

The current macro chain looks like:
KUNIT_EXPECT_STREQ => KUNIT_EXPECT_STREQ_MSG => KUNIT_BINARY_STR_EQ_MSG_ASSERTION => KUNIT_BINARY_STR_ASSERTION.
KUNIT_ASSERT_STREQ => KUNIT_ASSERT_STREQ_MSG => KUNIT_BINARY_STR_EQ_MSG_ASSERTION => KUNIT_BINARY_STR_ASSERTION.
<ditto for STR_NE>

After this change:
KUNIT_EXPECT_STREQ => KUNIT_EXPECT_STREQ_MSG => KUNIT_BINARY_STR_ASSERTION.
KUNIT_ASSERT_STREQ => KUNIT_ASSERT_STREQ_MSG => KUNIT_BINARY_STR_ASSERTION.
<ditto for STR_NE>

All the intermediate macro did was pass in "==" or "!=", so it seems
better to just drop them at the cost of a bit more copy-paste.
Signed-off-by: default avatarDaniel Latypov <dlatypov@google.com>
Reviewed-by: default avatarDavid Gow <davidgow@google.com>
Reviewed-by: default avatarBrendan Higgins <brendanhiggins@google.com>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent c5855907
......@@ -1098,30 +1098,6 @@ do { \
##__VA_ARGS__); \
} while (0)
#define KUNIT_BINARY_STR_EQ_MSG_ASSERTION(test, \
assert_type, \
left, \
right, \
fmt, \
...) \
KUNIT_BINARY_STR_ASSERTION(test, \
assert_type, \
left, ==, right, \
fmt, \
##__VA_ARGS__)
#define KUNIT_BINARY_STR_NE_MSG_ASSERTION(test, \
assert_type, \
left, \
right, \
fmt, \
...) \
KUNIT_BINARY_STR_ASSERTION(test, \
assert_type, \
left, !=, right, \
fmt, \
##__VA_ARGS__)
#define KUNIT_PTR_NOT_ERR_OR_NULL_MSG_ASSERTION(test, \
assert_type, \
ptr, \
......@@ -1371,12 +1347,11 @@ do { \
KUNIT_EXPECT_STREQ_MSG(test, left, right, NULL)
#define KUNIT_EXPECT_STREQ_MSG(test, left, right, fmt, ...) \
KUNIT_BINARY_STR_EQ_MSG_ASSERTION(test, \
KUNIT_EXPECTATION, \
left, \
right, \
fmt, \
##__VA_ARGS__)
KUNIT_BINARY_STR_ASSERTION(test, \
KUNIT_EXPECTATION, \
left, ==, right, \
fmt, \
##__VA_ARGS__)
/**
* KUNIT_EXPECT_STRNEQ() - Expects that strings @left and @right are not equal.
......@@ -1393,12 +1368,11 @@ do { \
KUNIT_EXPECT_STRNEQ_MSG(test, left, right, NULL)
#define KUNIT_EXPECT_STRNEQ_MSG(test, left, right, fmt, ...) \
KUNIT_BINARY_STR_NE_MSG_ASSERTION(test, \
KUNIT_EXPECTATION, \
left, \
right, \
fmt, \
##__VA_ARGS__)
KUNIT_BINARY_STR_ASSERTION(test, \
KUNIT_EXPECTATION, \
left, !=, right, \
fmt, \
##__VA_ARGS__)
/**
* KUNIT_EXPECT_NOT_ERR_OR_NULL() - Expects that @ptr is not null and not err.
......@@ -1648,12 +1622,11 @@ do { \
KUNIT_ASSERT_STREQ_MSG(test, left, right, NULL)
#define KUNIT_ASSERT_STREQ_MSG(test, left, right, fmt, ...) \
KUNIT_BINARY_STR_EQ_MSG_ASSERTION(test, \
KUNIT_ASSERTION, \
left, \
right, \
fmt, \
##__VA_ARGS__)
KUNIT_BINARY_STR_ASSERTION(test, \
KUNIT_ASSERTION, \
left, ==, right, \
fmt, \
##__VA_ARGS__)
/**
* KUNIT_ASSERT_STRNEQ() - Expects that strings @left and @right are not equal.
......@@ -1670,12 +1643,11 @@ do { \
KUNIT_ASSERT_STRNEQ_MSG(test, left, right, NULL)
#define KUNIT_ASSERT_STRNEQ_MSG(test, left, right, fmt, ...) \
KUNIT_BINARY_STR_NE_MSG_ASSERTION(test, \
KUNIT_ASSERTION, \
left, \
right, \
fmt, \
##__VA_ARGS__)
KUNIT_BINARY_STR_ASSERTION(test, \
KUNIT_ASSERTION, \
left, !=, right, \
fmt, \
##__VA_ARGS__)
/**
* KUNIT_ASSERT_NOT_ERR_OR_NULL() - Assertion that @ptr is not null and not err.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment