Merge branch 'master' into no-boost
This commit is contained in:
commit
96d95aa092
@ -45,8 +45,8 @@ cmake [-G generator] [-DBUILD_SHARED_LIBS=ON|OFF] ..
|
|||||||
|
|
||||||
# Recent Release #
|
# Recent Release #
|
||||||
|
|
||||||
[yaml-cpp 0.5.2](TODO) has been released! This is a bug fix release.
|
[yaml-cpp 0.5.2](https://github.com/jbeder/yaml-cpp/releases/tag/release-0.5.2) has been released! This is a bug fix release.
|
||||||
|
|
||||||
[yaml-cpp 0.3.0](TODO) is still available if you want the old API.
|
[yaml-cpp 0.3.0](https://github.com/jbeder/yaml-cpp/releases/tag/release-0.3.0) is still available if you want the old API.
|
||||||
|
|
||||||
**The old API will continue to be supported, and will still receive bugfixes!** The 0.3.x and 0.4.x versions will be old API releases, and 0.5.x and above will all be new API releases.
|
**The old API will continue to be supported, and will still receive bugfixes!** The 0.3.x and 0.4.x versions will be old API releases, and 0.5.x and above will all be new API releases.
|
||||||
|
|||||||
@ -149,7 +149,7 @@ inline const T Node::as() const {
|
|||||||
template <typename T, typename S>
|
template <typename T, typename S>
|
||||||
inline const T Node::as(const S& fallback) const {
|
inline const T Node::as(const S& fallback) const {
|
||||||
if (!m_isValid)
|
if (!m_isValid)
|
||||||
throw InvalidNode();
|
return fallback;
|
||||||
return as_if<T, S>(*this)(fallback);
|
return as_if<T, S>(*this)(fallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,26 +282,26 @@ inline std::size_t Node::size() const {
|
|||||||
|
|
||||||
inline const_iterator Node::begin() const {
|
inline const_iterator Node::begin() const {
|
||||||
if (!m_isValid)
|
if (!m_isValid)
|
||||||
throw InvalidNode();
|
return const_iterator();
|
||||||
return m_pNode ? const_iterator(m_pNode->begin(), m_pMemory)
|
return m_pNode ? const_iterator(m_pNode->begin(), m_pMemory)
|
||||||
: const_iterator();
|
: const_iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline iterator Node::begin() {
|
inline iterator Node::begin() {
|
||||||
if (!m_isValid)
|
if (!m_isValid)
|
||||||
throw InvalidNode();
|
return iterator();
|
||||||
return m_pNode ? iterator(m_pNode->begin(), m_pMemory) : iterator();
|
return m_pNode ? iterator(m_pNode->begin(), m_pMemory) : iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const_iterator Node::end() const {
|
inline const_iterator Node::end() const {
|
||||||
if (!m_isValid)
|
if (!m_isValid)
|
||||||
throw InvalidNode();
|
return const_iterator();
|
||||||
return m_pNode ? const_iterator(m_pNode->end(), m_pMemory) : const_iterator();
|
return m_pNode ? const_iterator(m_pNode->end(), m_pMemory) : const_iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline iterator Node::end() {
|
inline iterator Node::end() {
|
||||||
if (!m_isValid)
|
if (!m_isValid)
|
||||||
throw InvalidNode();
|
return iterator();
|
||||||
return m_pNode ? iterator(m_pNode->end(), m_pMemory) : iterator();
|
return m_pNode ? iterator(m_pNode->end(), m_pMemory) : iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -80,6 +80,12 @@ TEST(NodeTest, MapWithUndefinedValues) {
|
|||||||
EXPECT_EQ(2, node.size());
|
EXPECT_EQ(2, node.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(NodeTest, UndefinedConstNodeWithFallback) {
|
||||||
|
Node node;
|
||||||
|
const Node& cn = node;
|
||||||
|
EXPECT_EQ(cn["undefined"].as<int>(3), 3);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(NodeTest, MapIteratorWithUndefinedValues) {
|
TEST(NodeTest, MapIteratorWithUndefinedValues) {
|
||||||
Node node;
|
Node node;
|
||||||
node["key"] = "value";
|
node["key"] = "value";
|
||||||
@ -91,6 +97,32 @@ TEST(NodeTest, MapIteratorWithUndefinedValues) {
|
|||||||
EXPECT_EQ(1, count);
|
EXPECT_EQ(1, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(NodeTest, ConstIteratorOnConstUndefinedNode) {
|
||||||
|
Node node;
|
||||||
|
const Node& cn = node;
|
||||||
|
const Node& undefinedCn = cn["undefined"];
|
||||||
|
|
||||||
|
std::size_t count = 0;
|
||||||
|
for (const_iterator it = undefinedCn.begin(); it != undefinedCn.end(); ++it) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
EXPECT_EQ(0, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(NodeTest, IteratorOnConstUndefinedNode) {
|
||||||
|
Node node;
|
||||||
|
const Node& cn = node;
|
||||||
|
const Node& undefinedCn = cn["undefined"];
|
||||||
|
|
||||||
|
Node& nonConstUndefinedNode = const_cast<Node&>(undefinedCn);
|
||||||
|
|
||||||
|
std::size_t count = 0;
|
||||||
|
for (iterator it = nonConstUndefinedNode.begin(); it != nonConstUndefinedNode.end(); ++it) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
EXPECT_EQ(0, count);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(NodeTest, SimpleSubkeys) {
|
TEST(NodeTest, SimpleSubkeys) {
|
||||||
Node node;
|
Node node;
|
||||||
node["device"]["udid"] = "12345";
|
node["device"]["udid"] = "12345";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user