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/strongparser.h"
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
TEST(MADDY_STRONGPARSER, ItReplacesMarkdownWithStrongHTML)
|
|
|
|
{
|
2018-10-19 16:31:59 +02:00
|
|
|
struct testIt
|
|
|
|
{
|
|
|
|
std::string text;
|
|
|
|
std::string expected;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<testIt> tests
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"some text **bla** text testing **it** out",
|
|
|
|
"some text <strong>bla</strong> text testing <strong>it</strong> out"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"some text __bla__ text testing __it__ out",
|
|
|
|
"some text <strong>bla</strong> text testing <strong>it</strong> out"
|
|
|
|
},
|
|
|
|
};
|
2017-12-25 12:22:35 +01:00
|
|
|
|
2018-10-19 16:31:59 +02:00
|
|
|
auto strongParser = std::make_shared<maddy::StrongParser>();
|
2017-12-25 12:22:35 +01:00
|
|
|
|
2018-10-19 16:31:59 +02:00
|
|
|
for (auto& test : tests)
|
|
|
|
{
|
|
|
|
strongParser->Parse(test.text);
|
|
|
|
ASSERT_EQ(test.expected, test.text);
|
|
|
|
}
|
2017-12-25 12:22:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MADDY_STRONGPARSER, ItReplacesEmphasizedMarkdownNotWithStrongHTML)
|
|
|
|
{
|
2018-10-19 16:31:59 +02:00
|
|
|
struct testIt
|
|
|
|
{
|
|
|
|
std::string text;
|
|
|
|
std::string expected;
|
|
|
|
};
|
2017-12-25 12:22:35 +01:00
|
|
|
|
2018-10-19 16:31:59 +02:00
|
|
|
std::vector<testIt> tests
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"some text *bla* text testing **it** out",
|
|
|
|
"some text *bla* text testing <strong>it</strong> out"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"some text _bla_ text testing __it__ out",
|
|
|
|
"some text _bla_ text testing <strong>it</strong> out"
|
|
|
|
},
|
|
|
|
};
|
2017-12-25 12:22:35 +01:00
|
|
|
|
2018-10-19 16:31:59 +02:00
|
|
|
auto strongParser = std::make_shared<maddy::StrongParser>();
|
|
|
|
|
|
|
|
for (auto& test : tests)
|
|
|
|
{
|
|
|
|
strongParser->Parse(test.text);
|
|
|
|
ASSERT_EQ(test.expected, test.text);
|
|
|
|
}
|
2017-12-25 12:22:35 +01:00
|
|
|
}
|
2017-12-25 21:21:59 +01:00
|
|
|
|
|
|
|
TEST(MADDY_STRONGPARSER, ItDoesNotParseInsideInlineCode)
|
|
|
|
{
|
2018-10-19 16:31:59 +02:00
|
|
|
struct testIt
|
|
|
|
{
|
|
|
|
std::string text;
|
|
|
|
std::string expected;
|
|
|
|
};
|
2017-12-25 21:21:59 +01:00
|
|
|
|
2018-10-19 16:31:59 +02:00
|
|
|
std::vector<testIt> tests
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"some text **bla** `/**text**/` testing `**it**` out",
|
|
|
|
"some text **bla** `/**text**/` testing `**it**` out",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"some text _bla_ text testing __it__ out",
|
|
|
|
"some text _bla_ text testing <strong>it</strong> out"
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
auto strongParser = std::make_shared<maddy::StrongParser>();
|
2017-12-25 21:21:59 +01:00
|
|
|
|
2018-10-19 16:31:59 +02:00
|
|
|
for (auto& test : tests)
|
|
|
|
{
|
|
|
|
strongParser->Parse(test.text);
|
|
|
|
ASSERT_EQ(test.expected, test.text);
|
|
|
|
}
|
2017-12-25 21:21:59 +01:00
|
|
|
}
|