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

bblanchon / ArduinoJson / 18014952124

25 Sep 2025 05:01PM UTC coverage: 99.32% (-0.1%) from 99.418%
18014952124

push

github

bblanchon
Rewrite all converters

Before: 9802, 8486, 9630, 12418, 9654
After:  9802, 8446, 9630, 12242, 9660
Target: 9800, 8458, 9634, 12290, 9702

37 of 39 new or added lines in 1 file covered. (94.87%)

4 existing lines in 3 files now uncovered.

3945 of 3972 relevant lines covered (99.32%)

10265.19 hits per line

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

94.23
/src/ArduinoJson/Object/ObjectImpl.hpp
1
// ArduinoJson - https://arduinojson.org
2
// Copyright © 2014-2025, Benoit BLANCHON
3
// MIT License
4

5
#pragma once
6

7
#include <ArduinoJson/Object/ObjectData.hpp>
8
#include <ArduinoJson/Variant/VariantCompare.hpp>
9
#include <ArduinoJson/Variant/VariantData.hpp>
10

11
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
12

13
template <typename TAdaptedString>
14
inline VariantData* ObjectImpl::getMember(TAdaptedString key) const {
4,746✔
15
  auto it = findKey(key);
4,746✔
16
  if (it.done())
4,746✔
17
    return nullptr;
3,483✔
18
  it.next(resources_);
1,263✔
19
  return it.data();
1,263✔
20
}
21

22
template <typename TAdaptedString>
23
VariantData* ObjectImpl::getOrAddMember(TAdaptedString key) {
946✔
24
  auto data = getMember(key);
946✔
25
  if (data)
946✔
26
    return data;
34✔
27
  return addMember(key);
912✔
28
}
29

30
template <typename TAdaptedString>
31
inline ObjectImpl::iterator ObjectImpl::findKey(TAdaptedString key) const {
4,777✔
32
  if (key.isNull())
4,777✔
33
    return iterator();
13✔
34
  bool isKey = true;
4,764✔
35
  for (auto it = createIterator(); !it.done(); it.next(resources_)) {
25,612✔
36
    VariantImpl variant(it.data(), resources_);
22,137✔
37
    if (isKey && stringEquals(key, adaptString(VariantImpl::asString(
33,850✔
38
                                       it.data(), resources_))))
11,713✔
39
      return it;
1,289✔
40
    isKey = !isKey;
20,848✔
41
  }
42
  return iterator();
3,475✔
43
}
44

45
template <typename TAdaptedString>
46
inline void ObjectImpl::removeMember(TAdaptedString key) {
31✔
47
  remove(findKey(key));
31✔
48
}
31✔
49

50
template <typename TAdaptedString>
51
inline VariantData* ObjectImpl::addMember(TAdaptedString key) {
912✔
52
  if (!data_)
912✔
UNCOV
53
    return nullptr;
×
54
  ARDUINOJSON_ASSERT(resources_ != nullptr);
55

56
  auto keySlot = resources_->allocVariant();
912✔
57
  if (!keySlot)
912✔
58
    return nullptr;
2✔
59

60
  auto valueSlot = resources_->allocVariant();
910✔
61
  if (!valueSlot)
910✔
62
    return nullptr;
1✔
63

64
  if (!VariantImpl::setString(key, keySlot.ptr(), resources_))
909✔
65
    return nullptr;
2✔
66

67
  CollectionImpl::appendPair(keySlot, valueSlot);
907✔
68

69
  return valueSlot.ptr();
907✔
70
}
71

72
inline VariantData* ObjectImpl::addPair(VariantData** value) {
1,336✔
73
  if (!data_)
1,336✔
74
    return nullptr;
×
75
  ARDUINOJSON_ASSERT(resources_ != nullptr);
76

77
  auto keySlot = resources_->allocVariant();
1,336✔
78
  if (!keySlot)
1,336✔
79
    return nullptr;
4✔
80

81
  auto valueSlot = resources_->allocVariant();
1,332✔
82
  if (!valueSlot)
1,332✔
83
    return nullptr;
×
84
  *value = valueSlot.ptr();
1,332✔
85

86
  CollectionImpl::appendPair(keySlot, valueSlot);
1,332✔
87

88
  return keySlot.ptr();
1,332✔
89
}
90

91
// Returns the size (in bytes) of an object with n members.
92
constexpr size_t sizeofObject(size_t n) {
1,686✔
93
  return 2 * n * sizeof(VariantData);
1,686✔
94
}
95

96
ARDUINOJSON_END_PRIVATE_NAMESPACE
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