pw_assert: PW_CHECK_OK() macro for Status
This adds PW_CHECK_OK() for both C and C++ to assert that a Status
object or enum is OK.
Change-Id: I85e963bffc39510769feeb93e0b331f044557e7e
diff --git a/pw_assert/assert_backend_compile_test.c b/pw_assert/assert_backend_compile_test.c
index 599fa93..fb81a94 100644
--- a/pw_assert/assert_backend_compile_test.c
+++ b/pw_assert/assert_backend_compile_test.c
@@ -24,6 +24,7 @@
#define PW_ASSERT_USE_SHORT_NAMES 1
#include "pw_assert/assert.h"
+#include "pw_status/status.h"
#ifdef __cplusplus
#error "This file must be compiled as plain C to verify C compilation works."
@@ -182,4 +183,13 @@
CHECK_INT_LE(Add3(1, 2, 3), Add3(1, 2, 3), "INT: " FAIL_IF_DISPLAYED);
CHECK_INT_LE(x_int, y_int, "INT: " FAIL_IF_DISPLAYED_ARGS, z);
}
+
+ { // Compile tests for PW_ASSERT_OK().
+ PW_CHECK_OK(PW_STATUS_OK);
+ PW_CHECK_OK(PW_STATUS_OK, "msg");
+ PW_CHECK_OK(PW_STATUS_OK, "msg: %d", 5);
+ PW_DCHECK_OK(PW_STATUS_OK);
+ PW_DCHECK_OK(PW_STATUS_OK, "msg");
+ PW_DCHECK_OK(PW_STATUS_OK, "msg: %d", 5);
+ }
}