Added URL parser tests.

This commit is contained in:
Azareal 2018-09-20 11:11:44 +10:00
parent 6941786490
commit 138a97d69b
2 changed files with 11 additions and 0 deletions

View File

@ -1215,6 +1215,13 @@ func TestPreparser(t *testing.T) {
msgList = addMETri(msgList, "</strong>", "&lt;/strong&gt;")
msgList = addMETri(msgList, "<b>", "<strong></strong>")
msgList = addMETri(msgList, "<span style='background-color: yellow;'>hi", "hi")
msgList = addMETri(msgList, "//github.com/Azareal/Gosora", "<a href='//github.com/Azareal/Gosora'>//github.com/Azareal/Gosora</a>")
msgList = addMETri(msgList, "https://github.com/Azareal/Gosora", "<a href='https://github.com/Azareal/Gosora'>https://github.com/Azareal/Gosora</a>")
msgList = addMETri(msgList, "http://github.com/Azareal/Gosora", "<a href='http://github.com/Azareal/Gosora'>http://github.com/Azareal/Gosora</a>")
msgList = addMETri(msgList, "//github.com/Azareal/Gosora\n", "<a href='//github.com/Azareal/Gosora'>//github.com/Azareal/Gosora</a>")
msgList = addMETri(msgList, "\n//github.com/Azareal/Gosora", "<a href='//github.com/Azareal/Gosora'>//github.com/Azareal/Gosora</a>")
msgList = addMETri(msgList, "\n//github.com/Azareal/Gosora\n", "<a href='//github.com/Azareal/Gosora'>//github.com/Azareal/Gosora</a>")
msgList = addMETri(msgList, "//github.com/Azareal/Gosora\n//github.com/Azareal/Gosora", "<a href='//github.com/Azareal/Gosora'>//github.com/Azareal/Gosora</a>\n<a href='//github.com/Azareal/Gosora'>//github.com/Azareal/Gosora</a>")
msgList = addMETri(msgList, "hi</span>", "hi")
msgList = addMETri(msgList, "</span>", "")
msgList = addMETri(msgList, "<span></span>", "")

View File

@ -54,6 +54,10 @@ func TestBBCodeRender(t *testing.T) {
msgList = addMEPair(msgList, "[quote][b]hi[/b][/quote]", "<span class='postQuote'><b>hi</b></span>")
msgList = addMEPair(msgList, "[quote][b]h[/b][/quote]", "<span class='postQuote'><b>h</b></span>")
msgList = addMEPair(msgList, "[quote][b][/b][/quote]", "<span class='postQuote'><b></b></span>")
msgList = addMEPair(msgList, "[url][/url]", "<a href=''></a>")
msgList = addMEPair(msgList, "[url]https://github.com/Azareal/Gosora[/url]", "<a href='https://github.com/Azareal/Gosora'>https://github.com/Azareal/Gosora</a>")
msgList = addMEPair(msgList, "[url]http://github.com/Azareal/Gosora[/url]", "<a href='http://github.com/Azareal/Gosora'>http://github.com/Azareal/Gosora</a>")
msgList = addMEPair(msgList, "[url]//github.com/Azareal/Gosora[/url]", "<a href='//github.com/Azareal/Gosora'>//github.com/Azareal/Gosora</a>")
msgList = addMEPair(msgList, "-你好-", "-你好-")
msgList = addMEPair(msgList, "[i]-你好-[/i]", "<i>-你好-</i>") // TODO: More of these Unicode tests? Emoji, Chinese, etc.?