From 9c58e8d1e13d4a26dc75b8ca5ea46ba87b5e6a42 Mon Sep 17 00:00:00 2001 From: Snaipe Date: Tue, 8 Sep 2015 20:25:22 +0200 Subject: [PATCH] Added empty string assertions --- include/criterion/assert.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/criterion/assert.h b/include/criterion/assert.h index 092f7a1..ab57767 100644 --- a/include/criterion/assert.h +++ b/include/criterion/assert.h @@ -231,6 +231,29 @@ struct criterion_assert_args { // String assertions +# define cr_assert_str_op_empty_(Fail, Op, Value, ...) \ + CR_EXPAND(cr_assert_impl( \ + Fail, \ + (Value)[0] Op '\0', \ + dummy, \ + CR_STR(Value is empty.), \ + __VA_ARGS__ \ + )) + +# define cr_assert_str_op_empty_va_(Fail, Op, ...) \ + CR_EXPAND(cr_assert_str_op_empty_( \ + Fail, \ + Op, \ + CR_VA_HEAD(__VA_ARGS__), \ + CR_VA_TAIL(__VA_ARGS__) \ + )) + +# define cr_assert_str_empty(...) CR_EXPAND(cr_assert_str_op_empty_va_(CR_FAIL_ABORT_, ==, __VA_ARGS__)) +# define cr_expect_str_empty(...) CR_EXPAND(cr_assert_str_op_empty_va_(CR_FAIL_ABORT_, ==, __VA_ARGS__)) + +# define cr_assert_str_not_empty(...) CR_EXPAND(cr_assert_str_op_empty_va_(CR_FAIL_ABORT_, !=, __VA_ARGS__)) +# define cr_expect_str_not_empty(...) CR_EXPAND(cr_assert_str_op_empty_va_(CR_FAIL_ABORT_, !=, __VA_ARGS__)) + # define cr_assert_str_op_(Fail, Op, Actual, Expected, ...) \ CR_EXPAND(cr_assert_impl( \ Fail, \