aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/yassert_ut.cpp
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /util/system/yassert_ut.cpp
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'util/system/yassert_ut.cpp')
-rw-r--r--util/system/yassert_ut.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/util/system/yassert_ut.cpp b/util/system/yassert_ut.cpp
new file mode 100644
index 0000000000..ddd392666c
--- /dev/null
+++ b/util/system/yassert_ut.cpp
@@ -0,0 +1,35 @@
+#undef NDEBUG
+// yassert.h must be included before all headers
+#include "yassert.h"
+
+#include <library/cpp/testing/unittest/registar.h>
+
+Y_UNIT_TEST_SUITE(YassertTest) {
+ Y_UNIT_TEST(TestAcsLikeFunctionCall) {
+ if (true) {
+ Y_ASSERT(true); // this cannot be compiled if Y_ASSERT is "if (!cond) { ... }"
+ } else {
+ Y_ASSERT(false);
+ }
+
+ bool var = false;
+ if (false) {
+ Y_ASSERT(false);
+ } else {
+ var = true; // this is unreachable if Y_ASSERT is "if (!cond) { ... }"
+ }
+ UNIT_ASSERT(var);
+ }
+
+ Y_UNIT_TEST(TestFailCompiles) {
+ if (false) {
+ Y_FAIL("%d is a lucky number", 7);
+ Y_FAIL();
+ }
+ }
+
+ Y_UNIT_TEST(TestVerify) {
+ Y_VERIFY(true, "hi %s", "there");
+ Y_VERIFY(true);
+ }
+}