1
0
spogulis no https://github.com/quitesimpleorg/qsmaddy.git synced 2024-12-23 11:49:48 +01:00
qsmaddy/tests/maddy/test_maddy_paragraphparser.cpp
2017-12-25 12:22:35 +01:00

60 rindas
1.3 KiB
C++

/*
* This project is licensed under the MIT license. For more information see the
* LICENSE file.
*/
#include <memory>
#include "gmock/gmock.h"
#include "maddy/paragraphparser.h"
// -----------------------------------------------------------------------------
class MADDY_PARAGRAPHPARSER : public ::testing::Test
{
protected:
std::shared_ptr<maddy::ParagraphParser> pParser;
void
SetUp() override
{
this->pParser = std::make_shared<maddy::ParagraphParser>(
nullptr,
nullptr
);
}
};
// -----------------------------------------------------------------------------
TEST_F(MADDY_PARAGRAPHPARSER, IsStartingLineReturnsTrueWhenFacedWithThreeDashes)
{
ASSERT_TRUE(maddy::ParagraphParser::IsStartingLine("---"));
}
TEST_F(MADDY_PARAGRAPHPARSER, IsFinishedReturnsFalseInTheBeginning)
{
ASSERT_FALSE(pParser->IsFinished());
}
TEST_F(MADDY_PARAGRAPHPARSER, ItReplacesMarkdownWithAnHtmlLine)
{
std::vector<std::string> markdown = {
"Some text"
, "and some other text"
, ""
};
std::string expected = "<p>Some text and some other text </p>";
for (std::string md : markdown)
{
pParser->AddLine(md);
}
ASSERT_TRUE(pParser->IsFinished());
std::stringstream& output(pParser->GetResult());
const std::string& outputString = output.str();
ASSERT_EQ(expected, outputString);
}