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:
9760
test/integration/gen_emitter_test.cpp
Normal file
9760
test/integration/gen_emitter_test.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,14 +1,11 @@
|
||||
#include "specexamples.h" // IWYU pragma: keep
|
||||
#include "yaml-cpp/eventhandler.h"
|
||||
#include "handler_test.h"
|
||||
#include "specexamples.h" // IWYU pragma: keep
|
||||
#include "yaml-cpp/yaml.h" // IWYU pragma: keep
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::InSequence;
|
||||
using ::testing::NiceMock;
|
||||
using ::testing::StrictMock;
|
||||
|
||||
#define EXPECT_THROW_PARSER_EXCEPTION(statement, message) \
|
||||
ASSERT_THROW(statement, ParserException); \
|
||||
@@ -22,44 +19,7 @@ using ::testing::StrictMock;
|
||||
namespace YAML {
|
||||
namespace {
|
||||
|
||||
class MockEventHandler : public EventHandler {
|
||||
public:
|
||||
MOCK_METHOD1(OnDocumentStart, void(const Mark&));
|
||||
MOCK_METHOD0(OnDocumentEnd, void());
|
||||
|
||||
MOCK_METHOD2(OnNull, void(const Mark&, anchor_t));
|
||||
MOCK_METHOD2(OnAlias, void(const Mark&, anchor_t));
|
||||
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_METHOD0(OnSequenceEnd, void());
|
||||
|
||||
MOCK_METHOD3(OnMapStart, void(const Mark&, const std::string&, anchor_t));
|
||||
MOCK_METHOD0(OnMapEnd, void());
|
||||
};
|
||||
|
||||
class HandlerSpecTest : public ::testing::Test {
|
||||
protected:
|
||||
void Parse(const std::string& example) {
|
||||
std::stringstream stream(example);
|
||||
Parser parser(stream);
|
||||
while (parser.HandleNextDocument(handler)) {
|
||||
}
|
||||
}
|
||||
|
||||
void IgnoreParse(const std::string& example) {
|
||||
std::stringstream stream(example);
|
||||
Parser parser(stream);
|
||||
while (parser.HandleNextDocument(nice_handler)) {
|
||||
}
|
||||
}
|
||||
|
||||
InSequence sequence;
|
||||
StrictMock<MockEventHandler> handler;
|
||||
NiceMock<MockEventHandler> nice_handler;
|
||||
};
|
||||
typedef HandlerTest HandlerSpecTest;
|
||||
|
||||
TEST_F(HandlerSpecTest, Ex2_1_SeqScalars) {
|
||||
EXPECT_CALL(handler, OnDocumentStart(_));
|
||||
|
@@ -1,14 +1,11 @@
|
||||
#include "specexamples.h" // IWYU pragma: keep
|
||||
#include "yaml-cpp/eventhandler.h"
|
||||
#include "handler_test.h"
|
||||
#include "specexamples.h" // IWYU pragma: keep
|
||||
#include "yaml-cpp/yaml.h" // IWYU pragma: keep
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::InSequence;
|
||||
using ::testing::NiceMock;
|
||||
using ::testing::StrictMock;
|
||||
|
||||
#define EXPECT_THROW_PARSER_EXCEPTION(statement, message) \
|
||||
ASSERT_THROW(statement, ParserException); \
|
||||
@@ -22,45 +19,6 @@ using ::testing::StrictMock;
|
||||
namespace YAML {
|
||||
namespace {
|
||||
|
||||
class MockEventHandler : public EventHandler {
|
||||
public:
|
||||
MOCK_METHOD1(OnDocumentStart, void(const Mark&));
|
||||
MOCK_METHOD0(OnDocumentEnd, void());
|
||||
|
||||
MOCK_METHOD2(OnNull, void(const Mark&, anchor_t));
|
||||
MOCK_METHOD2(OnAlias, void(const Mark&, anchor_t));
|
||||
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_METHOD0(OnSequenceEnd, void());
|
||||
|
||||
MOCK_METHOD3(OnMapStart, void(const Mark&, const std::string&, anchor_t));
|
||||
MOCK_METHOD0(OnMapEnd, void());
|
||||
};
|
||||
|
||||
class HandlerTest : public ::testing::Test {
|
||||
protected:
|
||||
void Parse(const std::string& example) {
|
||||
std::stringstream stream(example);
|
||||
Parser parser(stream);
|
||||
while (parser.HandleNextDocument(handler)) {
|
||||
}
|
||||
}
|
||||
|
||||
void IgnoreParse(const std::string& example) {
|
||||
std::stringstream stream(example);
|
||||
Parser parser(stream);
|
||||
while (parser.HandleNextDocument(nice_handler)) {
|
||||
}
|
||||
}
|
||||
|
||||
InSequence sequence;
|
||||
StrictMock<MockEventHandler> handler;
|
||||
NiceMock<MockEventHandler> nice_handler;
|
||||
};
|
||||
|
||||
TEST_F(HandlerTest, NoEndOfMapFlow) {
|
||||
EXPECT_THROW_PARSER_EXCEPTION(IgnoreParse("---{header: {id: 1"),
|
||||
ErrorMsg::END_OF_MAP_FLOW);
|
||||
|
Reference in New Issue
Block a user