1
0
spegling av https://github.com/quitesimpleorg/qsmaddy.git synced 2024-11-24 16:22:36 +01:00
qsmaddy/tests/maddy/test_maddy_paragraphparser.cpp

60 rader
1.3 KiB
C++
Normal vy Historik

2017-12-25 12:22:35 +01:00
/*
* 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);
}