OSDN Git Service

Update TranslationsStatus
[winmerge-jp/winmerge-jp.git] / Testing / GoogleTest / markdown / markdown_test.cpp
1 #include "pch.h"
2 #include <gtest/gtest.h>
3 #include "markdown.h"
4
5 namespace
6 {
7         // The fixture for testing paths functions.
8         class MarkdownTest : public testing::Test
9         {
10         protected:
11                 // You can remove any or all of the following functions if its body
12                 // is   empty.
13
14                 MarkdownTest()
15                 {
16                         // You can do set-up work for each test here.
17                 }
18
19                 virtual ~MarkdownTest()
20                 {
21                         // You can do clean-up work     that doesn't throw exceptions here.
22                 }
23
24                 // If   the     constructor     and     destructor are not enough for setting up
25                 // and cleaning up each test, you can define the following methods:
26
27                 virtual void SetUp()
28                 {
29                         // Code here will be called     immediately     after the constructor (right
30                         // before each test).
31                 }
32
33                 virtual void TearDown()
34                 {
35                         // Code here will be called     immediately     after each test (right
36                         // before the destructor).
37                 }
38
39                 // Objects declared here can be used by all tests in the test case for Foo.
40         };
41
42         TEST_F(MarkdownTest, MarkdownTest1)
43         {
44                 const String html = 
45                         _T("<!DOCTYPE html>\r\n")
46             _T("<html>\r\n")
47             _T("<head>\r\n")
48             _T("<meta charset=\"UTF-8\">\r\n")
49             _T("<title>HTML5</title>\r\n")
50             _T("</head>\r\n")
51             _T("<body>\r\n")
52             _T("<div id='abc'>HTML5 test</div>\r\n")
53             _T("</body>\r\n")
54             _T("</html>\r\n");
55
56                 CMarkdown::File fi(html.c_str(), html.length() * sizeof(TCHAR), CMarkdown::Html|CMarkdown::FileImage::Mapping|CMarkdown::FileImage::Octets);
57                 fi.Move("meta");
58                 EXPECT_EQ("meta", fi.GetTagName());
59                 std::string content = fi.GetAttribute("context");
60                 EXPECT_EQ("", content);
61                 std::string charset = fi.GetAttribute("charset");
62                 EXPECT_EQ("UTF-8", charset);
63
64                 CMarkdown &pt = fi.Move("div");
65                 EXPECT_EQ("div", pt.GetTagName());
66                 EXPECT_EQ("div id='abc'", pt.GetTagText());
67                 EXPECT_EQ("<div id='abc'>HTML5 test</div>", pt.GetOuterText());
68                 EXPECT_EQ("HTML5 test", pt.GetInnerText());
69         }
70
71
72 }  // namespace