/* * This project is licensed under the MIT license. For more information see the * LICENSE file. */ #include #include "gmock/gmock.h" #include "maddy/codeblockparser.h" // ----------------------------------------------------------------------------- class MADDY_CODEBLOCKPARSER : public ::testing::Test { protected: std::shared_ptr cbParser; void SetUp() override { this->cbParser = std::make_shared( nullptr, nullptr ); } }; // ----------------------------------------------------------------------------- TEST_F(MADDY_CODEBLOCKPARSER, IsStartingLineReturnsTrueWhenFacedWithThreeSigns) { ASSERT_TRUE(maddy::CodeBlockParser::IsStartingLine("```")); } TEST_F(MADDY_CODEBLOCKPARSER, IsFinishedReturnsFalseInTheBeginning) { ASSERT_FALSE(cbParser->IsFinished()); } TEST_F(MADDY_CODEBLOCKPARSER, ItReplacesMarkdownWithAnHtmlCodeBlock) { std::vector markdown = { "```" , "some code" , "some other code" , "```" }; std::string expected = "
\nsome code\nsome other code\n
"; for (std::string md : markdown) { cbParser->AddLine(md); } ASSERT_TRUE(cbParser->IsFinished()); std::stringstream& output(cbParser->GetResult()); const std::string& outputString = output.str(); ASSERT_EQ(expected, outputString); }