mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 04:41:16 +00:00
Merge from core
This commit is contained in:
@@ -52,7 +52,7 @@ def scalar(value, tag='', anchor='', anchor_id=0):
|
||||
def comment(value):
|
||||
return {'emit': 'Comment("%s")' % value, 'handle': ''}
|
||||
|
||||
def seq_start(tag='', anchor='', anchor_id=0):
|
||||
def seq_start(tag='', anchor='', anchor_id=0, style='_'):
|
||||
emit = []
|
||||
if tag:
|
||||
emit += ['VerbatimTag("%s")' % encode(tag)]
|
||||
@@ -63,12 +63,12 @@ def seq_start(tag='', anchor='', anchor_id=0):
|
||||
else:
|
||||
out_tag = '?'
|
||||
emit += ['BeginSeq']
|
||||
return {'emit': emit, 'handle': 'OnSequenceStart(_, "%s", %s)' % (out_tag, anchor_id)}
|
||||
return {'emit': emit, 'handle': 'OnSequenceStart(_, "%s", %s, %s)' % (out_tag, anchor_id, style)}
|
||||
|
||||
def seq_end():
|
||||
return {'emit': 'EndSeq', 'handle': 'OnSequenceEnd()'}
|
||||
|
||||
def map_start(tag='', anchor='', anchor_id=0):
|
||||
def map_start(tag='', anchor='', anchor_id=0, style='_'):
|
||||
emit = []
|
||||
if tag:
|
||||
emit += ['VerbatimTag("%s")' % encode(tag)]
|
||||
@@ -79,7 +79,7 @@ def map_start(tag='', anchor='', anchor_id=0):
|
||||
else:
|
||||
out_tag = '?'
|
||||
emit += ['BeginMap']
|
||||
return {'emit': emit, 'handle': 'OnMapStart(_, "%s", %s)' % (out_tag, anchor_id)}
|
||||
return {'emit': emit, 'handle': 'OnMapStart(_, "%s", %s, %s)' % (out_tag, anchor_id, style)}
|
||||
|
||||
def map_end():
|
||||
return {'emit': 'EndMap', 'handle': 'OnMapEnd()'}
|
||||
|
@@ -1,3 +1,4 @@
|
||||
#include "yaml-cpp/emitterstyle.h"
|
||||
#include "yaml-cpp/eventhandler.h"
|
||||
#include "yaml-cpp/yaml.h" // IWYU pragma: keep
|
||||
#include "gtest/gtest.h"
|
||||
@@ -14,10 +15,12 @@ class NullEventHandler : public EventHandler {
|
||||
virtual void OnScalar(const Mark&, const std::string&, anchor_t,
|
||||
const std::string&) {}
|
||||
|
||||
virtual void OnSequenceStart(const Mark&, const std::string&, anchor_t) {}
|
||||
virtual void OnSequenceStart(const Mark&, const std::string&, anchor_t,
|
||||
EmitterStyle::value style) {}
|
||||
virtual void OnSequenceEnd() {}
|
||||
|
||||
virtual void OnMapStart(const Mark&, const std::string&, anchor_t) {}
|
||||
virtual void OnMapStart(const Mark&, const std::string&, anchor_t,
|
||||
EmitterStyle::value style) {}
|
||||
virtual void OnMapEnd() {}
|
||||
};
|
||||
|
||||
@@ -775,13 +778,13 @@ TEST_F(EmitterTest, Binary) {
|
||||
|
||||
TEST_F(EmitterTest, LongBinary) {
|
||||
out << Binary(
|
||||
reinterpret_cast<const unsigned char*>(
|
||||
"Man is distinguished, not only by his reason, but by this "
|
||||
"singular passion from other animals, which is a lust of the "
|
||||
"mind, that by a perseverance of delight in the continued and "
|
||||
"indefatigable generation of knowledge, exceeds the short "
|
||||
"vehemence of any carnal pleasure.\n"),
|
||||
270);
|
||||
reinterpret_cast<const unsigned char*>(
|
||||
"Man is distinguished, not only by his reason, but by this "
|
||||
"singular passion from other animals, which is a lust of the "
|
||||
"mind, that by a perseverance of delight in the continued and "
|
||||
"indefatigable generation of knowledge, exceeds the short "
|
||||
"vehemence of any carnal pleasure.\n"),
|
||||
270);
|
||||
ExpectEmit(
|
||||
"!!binary "
|
||||
"\"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieS"
|
||||
|
@@ -95,7 +95,7 @@ class EncodingTest : public HandlerTest {
|
||||
void Run() {
|
||||
InSequence sequence;
|
||||
EXPECT_CALL(handler, OnDocumentStart(_));
|
||||
EXPECT_CALL(handler, OnSequenceStart(_, "?", 0));
|
||||
EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
|
||||
for (std::size_t i = 0; i < m_entries.size(); i++) {
|
||||
EXPECT_CALL(handler, OnScalar(_, "!", 0, m_entries[i]));
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -11,8 +11,7 @@ using ::testing::_;
|
||||
ASSERT_THROW(statement, ParserException); \
|
||||
try { \
|
||||
statement; \
|
||||
} \
|
||||
catch (const ParserException& e) { \
|
||||
} catch (const ParserException& e) { \
|
||||
EXPECT_EQ(e.msg, message); \
|
||||
}
|
||||
|
||||
@@ -26,7 +25,7 @@ TEST_F(HandlerTest, NoEndOfMapFlow) {
|
||||
|
||||
TEST_F(HandlerTest, PlainScalarStartingWithQuestionMark) {
|
||||
EXPECT_CALL(handler, OnDocumentStart(_));
|
||||
EXPECT_CALL(handler, OnMapStart(_, "?", 0));
|
||||
EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
|
||||
EXPECT_CALL(handler, OnScalar(_, "?", 0, "foo"));
|
||||
EXPECT_CALL(handler, OnScalar(_, "?", 0, "?bar"));
|
||||
EXPECT_CALL(handler, OnMapEnd());
|
||||
@@ -36,7 +35,7 @@ TEST_F(HandlerTest, PlainScalarStartingWithQuestionMark) {
|
||||
|
||||
TEST_F(HandlerTest, NullStringScalar) {
|
||||
EXPECT_CALL(handler, OnDocumentStart(_));
|
||||
EXPECT_CALL(handler, OnMapStart(_, "?", 0));
|
||||
EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
|
||||
EXPECT_CALL(handler, OnScalar(_, "?", 0, "foo"));
|
||||
EXPECT_CALL(handler, OnNull(_, 0));
|
||||
EXPECT_CALL(handler, OnMapEnd());
|
||||
|
@@ -1,3 +1,4 @@
|
||||
#include "yaml-cpp/emitterstyle.h"
|
||||
#include "yaml-cpp/eventhandler.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
@@ -14,11 +15,12 @@ class MockEventHandler : public EventHandler {
|
||||
MOCK_METHOD4(OnScalar, void(const Mark&, const std::string&, anchor_t,
|
||||
const std::string&));
|
||||
|
||||
MOCK_METHOD3(OnSequenceStart,
|
||||
void(const Mark&, const std::string&, anchor_t));
|
||||
MOCK_METHOD4(OnSequenceStart, void(const Mark&, const std::string&, anchor_t,
|
||||
EmitterStyle::value));
|
||||
MOCK_METHOD0(OnSequenceEnd, void());
|
||||
|
||||
MOCK_METHOD3(OnMapStart, void(const Mark&, const std::string&, anchor_t));
|
||||
MOCK_METHOD4(OnMapStart, void(const Mark&, const std::string&, anchor_t,
|
||||
EmitterStyle::value));
|
||||
MOCK_METHOD0(OnMapEnd, void());
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user