• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

realm / realm-core / github_pull_request_278228

04 Oct 2023 10:15PM UTC coverage: 91.582% (+0.007%) from 91.575%
github_pull_request_278228

Pull #7029

Evergreen

tgoyne
Use UNITTEST_LOG_LEVEL in objectstore tests

For historical reasons core and sync tests use the UNITTEST_LOG_LEVEL
environment variable to determine the test log level, while object store tests
used a build time setting. This brings them into alignment on using the env
variable, and applies it via setting the default log level on startup in a
single place.
Pull Request #7029: Use UNITTEST_LOG_LEVEL in objectstore tests

94218 of 173442 branches covered (0.0%)

46 of 54 new or added lines in 5 files covered. (85.19%)

51 existing lines in 12 files now uncovered.

230351 of 251523 relevant lines covered (91.58%)

6704577.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/src/realm/util/assert.hpp
1
/*************************************************************************
2
 *
3
 * Copyright 2016 Realm Inc.
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 * http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 **************************************************************************/
18

19
#ifndef REALM_UTIL_ASSERT_HPP
20
#define REALM_UTIL_ASSERT_HPP
21

22
#include <realm/util/features.h>
23
#include <realm/util/terminate.hpp>
24

25
#if REALM_ENABLE_ASSERTIONS || defined(REALM_DEBUG)
26
#define REALM_ASSERTIONS_ENABLED 1
27
#else
28
#define REALM_ASSERTIONS_ENABLED 0
29
#endif
30

31
#define REALM_ASSERT_RELEASE(condition)                                                                              \
32
    (REALM_LIKELY(condition) ? static_cast<void>(0)                                                                  \
4,294,967,294✔
33
                             : realm::util::terminate("Assertion failed: " #condition, __FILE__, __LINE__))
4,294,967,294✔
34

35
#if REALM_ASSERTIONS_ENABLED
36
#define REALM_ASSERT(condition) REALM_ASSERT_RELEASE(condition)
4,294,967,294✔
37
#else
38
#define REALM_ASSERT(condition) static_cast<void>(sizeof bool(condition))
420✔
39
#endif
40

41
#ifdef REALM_DEBUG
42
#define REALM_ASSERT_DEBUG(condition) REALM_ASSERT_RELEASE(condition)
4,294,967,294✔
43
#else
44
#define REALM_ASSERT_DEBUG(condition) static_cast<void>(sizeof bool(condition))
321,132✔
45
#endif
46

47
#define REALM_STRINGIFY(X) #X
53,110,328✔
48

49
#define REALM_ASSERT_RELEASE_EX(condition, ...)                                                                      \
50
    (REALM_LIKELY(condition) ? static_cast<void>(0)                                                                  \
4,294,967,294✔
51
                             : realm::util::terminate_with_info("Assertion failed: " #condition, __LINE__, __FILE__, \
2,164,894,639✔
52
                                                                REALM_STRINGIFY((__VA_ARGS__)), __VA_ARGS__))
53,110,328✔
53

54
#ifdef REALM_DEBUG
55
#define REALM_ASSERT_DEBUG_EX REALM_ASSERT_RELEASE_EX
4,200,445,281✔
56
#else
57
#define REALM_ASSERT_DEBUG_EX(condition, ...) static_cast<void>(sizeof bool(condition))
126,042✔
58
#endif
59

60
// Becase the assert is used in noexcept methods, it's a bad idea to allocate
61
// buffer space for the message so therefore we must pass it to terminate which
62
// will 'cerr' it for us without needing any buffer
63
#if REALM_ENABLE_ASSERTIONS || defined(REALM_DEBUG)
64

65
#define REALM_ASSERT_EX REALM_ASSERT_RELEASE_EX
401,410,842✔
66

67
#define REALM_ASSERT_3(left, cmp, right)                                                                             \
68
    (REALM_LIKELY((left)cmp(right)) ? static_cast<void>(0)                                                           \
4,294,967,294✔
69
                                    : realm::util::terminate("Assertion failed: "                                    \
2,157,092,369✔
70
                                                             "" #left " " #cmp " " #right,                           \
20,931,542✔
71
                                                             __FILE__, __LINE__, left, right))
20,931,542✔
72

73
#define REALM_ASSERT_7(left1, cmp1, right1, logical, left2, cmp2, right2)                                            \
74
    (REALM_LIKELY(((left1)cmp1(right1))logical((left2)cmp2(right2)))                                                 \
100,727,205✔
75
         ? static_cast<void>(0)                                                                                      \
100,863,312✔
76
         : realm::util::terminate("Assertion failed: "                                                               \
4,294,967,294✔
77
                                  "" #left1 " " #cmp1 " " #right1 " " #logical " "                                   \
4,294,967,294✔
78
                                  "" #left2 " " #cmp2 " " #right2,                                                   \
4,294,967,294✔
79
                                  __FILE__, __LINE__, left1, right1, left2, right2))
4,294,967,294✔
80

81
#define REALM_ASSERT_11(left1, cmp1, right1, logical1, left2, cmp2, right2, logical2, left3, cmp3, right3)           \
82
    (REALM_LIKELY(((left1)cmp1(right1))logical1((left2)cmp2(right2)) logical2((left3)cmp3(right3)))                  \
361,149✔
83
         ? static_cast<void>(0)                                                                                      \
361,149✔
84
         : realm::util::terminate("Assertion failed: "                                                               \
190,548✔
UNCOV
85
                                  "" #left1 " " #cmp1 " " #right1 " " #logical1 " "                                  \
×
UNCOV
86
                                  "" #left2 " " #cmp2 " " #right2 " " #logical2 " "                                  \
×
UNCOV
87
                                  "" #left3 " " #cmp3 " " #right3,                                                   \
×
UNCOV
88
                                  __FILE__, __LINE__, left1, right1, left2, right2, left3, right3))
×
89
#else
90
#define REALM_ASSERT_EX(condition, ...) static_cast<void>(sizeof bool(condition))
91
#define REALM_ASSERT_3(left, cmp, right) static_cast<void>(sizeof bool((left)cmp(right)))
92
#define REALM_ASSERT_7(left1, cmp1, right1, logical, left2, cmp2, right2)                                            \
93
    static_cast<void>(sizeof bool(((left1)cmp1(right1))logical((left2)cmp2(right2))))
94
#define REALM_ASSERT_11(left1, cmp1, right1, logical1, left2, cmp2, right2, logical2, left3, cmp3, right3)           \
95
    static_cast<void>(sizeof bool(((left1)cmp1(right1))logical1((left2)cmp2(right2)) logical2((left3)cmp3(right3))))
96
#endif
97

98
#define REALM_UNREACHABLE() realm::util::terminate("Unreachable code", __FILE__, __LINE__)
4,294,967,294✔
99
#ifdef REALM_COVER
100
#define REALM_COVER_NEVER(x) false
101
#define REALM_COVER_ALWAYS(x) true
102
#else
103
#define REALM_COVER_NEVER(x) (x)
117,241,110✔
104
#define REALM_COVER_ALWAYS(x) (x)
105
#endif
106

107
#endif // REALM_UTIL_ASSERT_HPP
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc