kunit: mock: added bool matchers
Added matchers for bool parameters.
Signed-off-by: Sagi Shahar <sagis@google.com>
Change-Id: I39e3d52251338e8cd937698b2941184fa6e876f2
diff --git a/include/test/mock.h b/include/test/mock.h
index 4d8dfa9..e37ab9f 100644
--- a/include/test/mock.h
+++ b/include/test/mock.h
@@ -1244,6 +1244,10 @@ struct mock_param_matcher *ulonglong_ge(struct test *test,
struct mock_param_matcher *ulonglong_gt(struct test *test,
unsigned long long expected);
+/* matches booleans. */
+struct mock_param_matcher *bool_eq(struct test *test, bool expected);
+struct mock_param_matcher *bool_ne(struct test *test, bool expected);
+
/* Matches pointers. */
struct mock_param_matcher *ptr_eq(struct test *test, void *expected);
struct mock_param_matcher *ptr_ne(struct test *test, void *expected);
diff --git a/test/common-mocks.c b/test/common-mocks.c
index 3e15b5c..e128ef3 100644
--- a/test/common-mocks.c
+++ b/test/common-mocks.c
@@ -120,6 +120,13 @@ DEFINE_MATCHER_WITH_TYPENAME(ulonglong, unsigned long long);
DEFINE_MATCHER_WITH_TYPENAME(ptr, void *);
+DEFINE_MATCHER_STRUCT(bool, bool)
+DEFINE_TO_MATCHER_STRUCT(bool)
+DEFINE_MATCH_FUNC(bool, bool, eq, ==)
+DEFINE_MATCH_FACTORY(bool, bool, eq)
+DEFINE_MATCH_FUNC(bool, bool, ne, !=)
+DEFINE_MATCH_FACTORY(bool, bool, ne)
+
struct mock_memeq_matcher {
struct mock_param_matcher matcher;
const void *expected;