mirror of
https://github.com/quitesimpleorg/qsmaddy.git
synced 2025-12-18 20:21:44 +01:00
initial release 1.0.0
This commit is contained in:
62
tests/maddy/test_maddy_quoteparser.cpp
Normal file
62
tests/maddy/test_maddy_quoteparser.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* This project is licensed under the MIT license. For more information see the
|
||||
* LICENSE file.
|
||||
*/
|
||||
#include <memory>
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
#include "maddy/quoteparser.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
class MADDY_QUOTEPARSER : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
std::shared_ptr<maddy::QuoteParser> quoteParser;
|
||||
|
||||
void
|
||||
SetUp() override
|
||||
{
|
||||
this->quoteParser = std::make_shared<maddy::QuoteParser>(
|
||||
nullptr,
|
||||
nullptr
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
TEST_F(MADDY_QUOTEPARSER, IsStartingLineReturnsTrueWhenFacedWithBeginningOfAQuote)
|
||||
{
|
||||
ASSERT_TRUE(maddy::QuoteParser::IsStartingLine("> a"));
|
||||
}
|
||||
|
||||
TEST_F(MADDY_QUOTEPARSER, IsFinishedAlwaysReturnsFalseInTheBeginning)
|
||||
{
|
||||
ASSERT_FALSE(quoteParser->IsFinished());
|
||||
}
|
||||
|
||||
TEST_F(MADDY_QUOTEPARSER, ItReplacesMarkdownWithAnHtmlBlockQuote)
|
||||
{
|
||||
std::vector<std::string> markdown = {
|
||||
"> a"
|
||||
, "> b"
|
||||
, ">"
|
||||
, "> c"
|
||||
, ""
|
||||
};
|
||||
std::string expected = "<blockquote>a b c </blockquote>";
|
||||
|
||||
for (std::string md : markdown)
|
||||
{
|
||||
quoteParser->AddLine(md);
|
||||
}
|
||||
|
||||
ASSERT_TRUE(quoteParser->IsFinished());
|
||||
|
||||
std::stringstream& output(quoteParser->GetResult());
|
||||
const std::string& outputString = output.str();
|
||||
|
||||
ASSERT_EQ(expected, outputString);
|
||||
}
|
||||
Reference in New Issue
Block a user