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:
44
tests/maddy/test_maddy_imageparser.cpp
Normal file
44
tests/maddy/test_maddy_imageparser.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This project is licensed under the MIT license. For more information see the
|
||||
* LICENSE file.
|
||||
*/
|
||||
#include <memory>
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
#include "maddy/imageparser.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
TEST(MADDY_IMAGEPARSER, ItReplacesMarkdownWithAnImage)
|
||||
{
|
||||
std::string text = "Some text ";
|
||||
std::string expected = "Some text <img src=\"http://example.com/a.png\" alt=\"Image Title\"/>";
|
||||
auto imageParser = std::make_shared<maddy::ImageParser>();
|
||||
|
||||
imageParser->Parse(text);
|
||||
|
||||
ASSERT_EQ(expected, text);
|
||||
}
|
||||
|
||||
TEST(MADDY_IMAGEPARSER, ItReplacesMarkdownWithImages)
|
||||
{
|
||||
std::string text = "Some text  bla ";
|
||||
std::string expected = "Some text <img src=\"http://example.com/a.png\" alt=\"Image Title\"/> bla <img src=\"http://example.com/a.png\" alt=\"Image Title\"/>";
|
||||
auto imageParser = std::make_shared<maddy::ImageParser>();
|
||||
|
||||
imageParser->Parse(text);
|
||||
|
||||
ASSERT_EQ(expected, text);
|
||||
}
|
||||
|
||||
TEST(MADDY_IMAGEPARSER, ItReplacesNoLinkMarkdownWithImages)
|
||||
{
|
||||
std::string text = "Some text [Image Title](http://example.com)";
|
||||
std::string expected(text);
|
||||
auto imageParser = std::make_shared<maddy::ImageParser>();
|
||||
|
||||
imageParser->Parse(text);
|
||||
|
||||
ASSERT_EQ(expected, text);
|
||||
}
|
||||
Reference in New Issue
Block a user