aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/yassert_ut.cpp
blob: 6c1da535a4fecf38fbb8181c6018856bd9f80483 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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);
    }
}