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

realm / realm-core / github_pull_request_312964

19 Feb 2025 07:31PM UTC coverage: 90.814% (-0.3%) from 91.119%
github_pull_request_312964

Pull #8071

Evergreen

web-flow
Bump serialize-javascript and mocha

Bumps [serialize-javascript](https://github.com/yahoo/serialize-javascript) to 6.0.2 and updates ancestor dependency [mocha](https://github.com/mochajs/mocha). These dependencies need to be updated together.


Updates `serialize-javascript` from 6.0.0 to 6.0.2
- [Release notes](https://github.com/yahoo/serialize-javascript/releases)
- [Commits](https://github.com/yahoo/serialize-javascript/compare/v6.0.0...v6.0.2)

Updates `mocha` from 10.2.0 to 10.8.2
- [Release notes](https://github.com/mochajs/mocha/releases)
- [Changelog](https://github.com/mochajs/mocha/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mochajs/mocha/compare/v10.2.0...v10.8.2)

---
updated-dependencies:
- dependency-name: serialize-javascript
  dependency-type: indirect
- dependency-name: mocha
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #8071: Bump serialize-javascript and mocha

96552 of 179126 branches covered (53.9%)

212672 of 234185 relevant lines covered (90.81%)

3115802.0 hits per line

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

0.0
/test/util/verified_string.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 <algorithm>
20

21
#include "verified_string.hpp"
22
#include "realm/array_key.hpp"
23

24
using namespace realm;
25
using namespace realm::test_util;
26

27

28
VerifiedString::VerifiedString()
29
    : u(Allocator::get_default())
×
30
{
×
31
    u.create();
×
32
}
×
33

34

35
VerifiedString::~VerifiedString()
36
{
×
37
    u.destroy();
×
38
}
×
39

40
void VerifiedString::verify_neighbours(size_t ndx)
41
{
×
42
    if (v.size() > ndx)
×
43
        REALM_ASSERT(v[ndx] == u.get(ndx));
×
44

45
    if (ndx > 0)
×
46
        REALM_ASSERT(v[ndx - 1] == u.get(ndx - 1));
×
47

48
    if (v.size() > ndx + 1)
×
49
        REALM_ASSERT(v[ndx + 1] == u.get(ndx + 1));
×
50
}
×
51

52
void VerifiedString::add(StringData value)
53
{
×
54
    v.push_back(value);
×
55
    u.add(value);
×
56
    REALM_ASSERT(v.size() == u.size());
×
57
    verify_neighbours(v.size());
×
58
    REALM_ASSERT(conditional_verify());
×
59
}
×
60

61

62
void VerifiedString::insert(size_t ndx, StringData value)
63
{
×
64
    v.insert(v.begin() + ndx, value);
×
65
    u.insert(ndx, value);
×
66
    REALM_ASSERT(v.size() == u.size());
×
67
    verify_neighbours(ndx);
×
68
    REALM_ASSERT(conditional_verify());
×
69
}
×
70

71

72
StringData VerifiedString::get(size_t ndx)
73
{
×
74
    REALM_ASSERT(v[ndx] == u.get(ndx));
×
75
    return v[ndx];
×
76
}
×
77

78
void VerifiedString::set(size_t ndx, StringData value)
79
{
×
80
    v[ndx] = value;
×
81
    u.set(ndx, value);
×
82
    verify_neighbours(ndx);
×
83
    REALM_ASSERT(conditional_verify());
×
84
}
×
85

86
void VerifiedString::erase(size_t ndx)
87
{
×
88
    v.erase(v.begin() + ndx);
×
89
    u.erase(ndx);
×
90
    REALM_ASSERT(v.size() == u.size());
×
91
    verify_neighbours(ndx);
×
92
    REALM_ASSERT(conditional_verify());
×
93
}
×
94

95
void VerifiedString::clear()
96
{
×
97
    v.clear();
×
98
    u.clear();
×
99
    REALM_ASSERT(v.size() == u.size());
×
100
    REALM_ASSERT(conditional_verify());
×
101
}
×
102

103
size_t VerifiedString::find_first(StringData value)
104
{
×
105
    std::vector<std::string>::iterator it = std::find(v.begin(), v.end(), value);
×
106
    size_t ndx = std::distance(v.begin(), it);
×
107
    size_t index2 = u.find_first(value);
×
108
    static_cast<void>(index2);
×
109
    REALM_ASSERT(ndx == index2 || (it == v.end() && index2 == size_t(-1)));
×
110
    return ndx;
×
111
}
×
112

113
size_t VerifiedString::size()
114
{
×
115
    REALM_ASSERT(v.size() == u.size());
×
116
    return v.size();
×
117
}
×
118

119
bool VerifiedString::verify()
120
{
×
121
    REALM_ASSERT(u.size() == v.size());
×
122
    if (u.size() != v.size())
×
123
        return false;
×
124

125
    for (size_t t = 0; t < v.size(); ++t) {
×
126
        REALM_ASSERT(v[t] == u.get(t));
×
127
        if (v[t] != u.get(t))
×
128
            return false;
×
129
    }
×
130
    return true;
×
131
}
×
132

133
// makes it run amortized the same time complexity as original, even though the row count grows
134
bool VerifiedString::conditional_verify()
135
{
×
136
    if ((uint64_t(rand()) * uint64_t(rand())) % (v.size() / 10 + 1) == 0) {
×
137
        return verify();
×
138
    }
×
139
    else {
×
140
        return true;
×
141
    }
×
142
}
×
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