package web import ( "github.com/stretchrcom/testify/assert" "html/template" "testing" ) func TestTextToHtml(t *testing.T) { // Identity assert.Equal(t, textToHtml("html"), template.HTML("html")) // Check it escapes assert.Equal(t, textToHtml(""), template.HTML("<html>")) // Check for linebreaks assert.Equal(t, textToHtml("line\nbreak"), template.HTML("line
\nbreak")) assert.Equal(t, textToHtml("line\r\nbreak"), template.HTML("line
\nbreak")) assert.Equal(t, textToHtml("line\rbreak"), template.HTML("line
\nbreak")) } func TestURLDetection(t *testing.T) { assert.Equal(t, textToHtml("http://google.com/"), template.HTML("http://google.com/")) assert.Equal(t, textToHtml("http://a.com/?q=a&n=v"), template.HTML("http://a.com/?q=a&n=v")) }