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

realm / realm-core / jorgen.edelbo_390

12 Aug 2024 12:13PM UTC coverage: 91.108% (+0.02%) from 91.085%
jorgen.edelbo_390

Pull #7979

Evergreen

jedelbo
Create test file in file-format 24
Pull Request #7979: Create test file in file-format 24

102766 of 181590 branches covered (56.59%)

19 of 19 new or added lines in 1 file covered. (100.0%)

1020 existing lines in 55 files now uncovered.

217365 of 238579 relevant lines covered (91.11%)

5621116.99 hits per line

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

82.35
/src/realm/impl/output_stream.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 <limits>
20
#include <stdexcept>
21

22
#include <realm/util/safe_int_ops.hpp>
23
#include <realm/util/backtrace.hpp>
24
#include <realm/impl/output_stream.hpp>
25

26
using namespace realm;
27
using namespace realm::util;
28
using namespace realm::_impl;
29

30

31
void OutputStream::write(const char* data, size_t size)
32
{
1,350✔
33
    REALM_ASSERT(size % 8 == 0);
1,350✔
34

35
    do_write(data, size); // Throws
1,350✔
36

37
    if (int_add_with_overflow_detect(m_next_ref, size))
1,350✔
38
        throw util::overflow_error("Stream size overflow");
×
39
}
1,350✔
40

41

42
ref_type OutputStream::write_array(const char* data, size_t size, uint32_t checksum)
43
{
68,160✔
44
    REALM_ASSERT(size % 8 == 0);
68,160✔
45

46
    const char* data_1 = data;
68,160✔
47
    size_t size_1 = size;
68,160✔
48

49
    const char* cksum_bytes = reinterpret_cast<const char*>(&checksum);
68,160✔
50
    m_out.write(cksum_bytes, 4); // Throws
68,160✔
51
    data_1 += 4;
68,160✔
52
    size_1 -= 4;
68,160✔
53

54
    do_write(data_1, size_1); // Throws
68,160✔
55

56
    ref_type ref = m_next_ref;
68,160✔
57
    if (int_add_with_overflow_detect(m_next_ref, size))
68,160✔
UNCOV
58
        throw util::overflow_error("Stream size overflow");
×
59

60
    return ref;
68,160✔
61
}
68,160✔
62

63

64
void OutputStream::do_write(const char* data, size_t size)
65
{
69,510✔
66
    const char* data_1 = data;
69,510✔
67
    size_t size_1 = size;
69,510✔
68

69
    // Handle the case where 'size_t' has a larger range than 'std::streamsize'
70
    std::streamsize max_streamsize = std::numeric_limits<std::streamsize>::max();
69,510✔
71
    size_t max_put = std::numeric_limits<size_t>::max();
69,510✔
72
    if (int_less_than(max_streamsize, max_put))
69,510✔
73
        max_put = size_t(max_streamsize);
69,510✔
74
    while (max_put < size_1) {
69,510✔
UNCOV
75
        m_out.write(data_1, max_put); // Throws
×
76
        data_1 += max_put;
×
77
        size_1 -= max_put;
×
78
    }
×
79

80
    m_out.write(data_1, size_1); // Throws
69,510✔
81
}
69,510✔
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

© 2026 Coveralls, Inc