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

realm / realm-core / michael.wilkersonbarker_1147

04 Jun 2024 01:18PM UTC coverage: 90.835% (-0.008%) from 90.843%
michael.wilkersonbarker_1147

Pull #7542

Evergreen

michael-wb
Removed unused SyncClientHookEvent entries
Pull Request #7542: RCORE-2063 Fix some client resets potentially failing with AutoClientResetFailed if a new client reset condition occurred before the first one completed

101700 of 180094 branches covered (56.47%)

61 of 66 new or added lines in 5 files covered. (92.42%)

84 existing lines in 12 files now uncovered.

214628 of 236283 relevant lines covered (90.84%)

5386848.77 hits per line

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

96.55
/src/realm/array_key.cpp
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
#include <realm/array_key.hpp>
20
#include <realm/table.hpp>
21

22
namespace realm {
23

24
// This is used for linklists
25
template <>
26
void ArrayKeyBase<0>::verify() const
27
{
7,866✔
28
#ifdef REALM_DEBUG
7,866✔
29
    Array::verify();
7,866✔
30
    // We have to get parent until we reach the containing cluster
31
    auto parent = get_parent();
7,866✔
32
    size_t origin_obj_ndx;
7,866✔
33
    size_t origin_col_ndx = get_ndx_in_parent();
7,866✔
34
    Cluster* cluster = nullptr;
7,866✔
35
    do {
7,866✔
36
        REALM_ASSERT(parent);
7,866✔
37
        auto arr = dynamic_cast<Array*>(parent);
7,866✔
38
        REALM_ASSERT(arr);
7,866✔
39
        parent = arr->get_parent();
7,866✔
40
        // When we reach the cluster, the previous value of
41
        // origin_col_ndx will be the object index in the cluster.
42
        origin_obj_ndx = origin_col_ndx;
7,866✔
43
        // When we reach the cluster, arr will point to the ArrayRef leaf and the
44
        // origin_col_ndx will give the position in the cluster array.
45
        origin_col_ndx = arr->get_ndx_in_parent();
7,866✔
46
        cluster = dynamic_cast<Cluster*>(parent);
7,866✔
47
    } while (parent && !cluster);
7,866✔
48

49
    REALM_ASSERT(cluster);
7,866✔
50
    const Table* origin_table = cluster->get_owning_table();
7,866✔
51
    ObjKey origin_key = cluster->get_real_key(origin_obj_ndx);
7,866✔
52
    ColKey link_col_key = cluster->get_col_key(origin_col_ndx);
7,866✔
53

54
    TableRef target_table = origin_table->get_opposite_table(link_col_key);
7,866✔
55

56
    auto verify_link = [origin_table, link_col_key, origin_key](const Obj& target_obj) {
27,438✔
57
        auto cnt = target_obj.get_backlink_count(*origin_table, link_col_key);
27,438✔
58
        for (size_t i = 0; i < cnt; i++) {
9,018,405✔
59
            if (target_obj.get_backlink(*origin_table, link_col_key, i) == origin_key)
9,018,405✔
60
                return;
27,438✔
61
        }
9,018,405✔
UNCOV
62
        REALM_ASSERT(false);
×
UNCOV
63
    };
×
64

65
    // Verify that forward link has a corresponding backlink
66
    for (size_t i = 0; i < size(); ++i) {
35,304✔
67
        if (ObjKey target_key = get(i)) {
27,438✔
68
            auto target_obj = target_key.is_unresolved() ? target_table->try_get_tombstone(target_key)
27,438✔
69
                                                         : target_table->try_get_object(target_key);
27,438✔
70
            REALM_ASSERT(target_obj);
27,438✔
71
            verify_link(target_obj);
27,438✔
72
        }
27,438✔
73
    }
27,438✔
74
#endif
7,866✔
75
}
7,866✔
76

77
// This is used for single links
78
template <>
79
void ArrayKeyBase<1>::verify() const
80
{
1,617✔
81
#ifdef REALM_DEBUG
1,617✔
82
    Array::verify();
1,617✔
83
    REALM_ASSERT(dynamic_cast<Cluster*>(get_parent()));
1,617✔
84
    auto cluster = static_cast<Cluster*>(get_parent());
1,617✔
85
    const Table* origin_table = cluster->get_owning_table();
1,617✔
86
    ColKey link_col_key = cluster->get_col_key(get_ndx_in_parent());
1,617✔
87

88
    ConstTableRef target_table = origin_table->get_opposite_table(link_col_key);
1,617✔
89

90
    // Verify that forward link has a corresponding backlink
91
    for (size_t i = 0; i < size(); ++i) {
137,118✔
92
        if (ObjKey target_key = get(i)) {
135,501✔
93
            ObjKey origin_key = cluster->get_real_key(i);
126,690✔
94

95
            auto target_obj = target_key.is_unresolved() ? target_table->try_get_tombstone(target_key)
126,690✔
96
                                                         : target_table->try_get_object(target_key);
126,690✔
97
            REALM_ASSERT(target_obj);
126,690✔
98
            target_obj.verify_backlink(*origin_table, link_col_key, origin_key);
126,690✔
99
        }
126,690✔
100
    }
135,501✔
101
#endif
1,617✔
102
}
1,617✔
103

104
} // namespace realm
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