yaml-cpp/test/parser_test.cpp

30 lines
749 B
C++
Raw Normal View History

#include "yaml-cpp/parser.h"
2020-01-20 18:25:05 +03:00
#include "yaml-cpp/exceptions.h"
#include "mock_event_handler.h"
#include "gtest/gtest.h"
using YAML::Parser;
using YAML::MockEventHandler;
2020-01-20 18:25:05 +03:00
using ::testing::NiceMock;
using ::testing::StrictMock;
TEST(ParserTest, Empty) {
Parser parser;
EXPECT_FALSE(parser);
StrictMock<MockEventHandler> handler;
EXPECT_FALSE(parser.HandleNextDocument(handler));
}
2020-01-20 18:25:05 +03:00
TEST(ParserTest, CVE_2017_5950) {
std::string excessive_recursion;
for (auto i = 0; i != 16384; ++i)
excessive_recursion.push_back('[');
std::istringstream input{excessive_recursion};
Parser parser{input};
NiceMock<MockEventHandler> handler;
EXPECT_THROW(parser.HandleNextDocument(handler), YAML::ParserException);
}