/* * This project is licensed under the MIT license. For more information see the * LICENSE file. */ #include #include "gmock/gmock.h" #include "maddy/tableparser.h" // ----------------------------------------------------------------------------- class MADDY_TABLEPARSER : public ::testing::Test { protected: std::shared_ptr tableParser; void SetUp() override { this->tableParser = std::make_shared( nullptr, nullptr ); } }; // ----------------------------------------------------------------------------- TEST_F(MADDY_TABLEPARSER, IsStartingLineReturnsTrueWhenFacedWithTheBeginningOfATable) { ASSERT_EQ(true, maddy::TableParser::IsStartingLine("|table>")); } TEST_F(MADDY_TABLEPARSER, IsFinishedReturnsFalseInTheBeginning) { ASSERT_FALSE(tableParser->IsFinished()); } TEST_F(MADDY_TABLEPARSER, ItReplacesMarkdownWithAnHtmlTable) { std::vector markdown = { "|table>" , "Left header|middle header|last header" , "- | - | -" , "cell 1|cell 2|cell 3" , "cell 4|cell 5|cell 6" , "- | - | -" , "foot a|foot b|foot c" , "|AddLine(md); } ASSERT_TRUE(tableParser->IsFinished()); std::stringstream& output(tableParser->GetResult()); const std::string& outputString = output.str(); ASSERT_EQ(expected, outputString); }