1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-03-19 21:10:15 +02:00
chroma/formatters/html/html_test.go

30 lines
711 B
Go
Raw Normal View History

package html
import (
2017-09-19 23:04:10 +10:00
"io/ioutil"
"testing"
2017-09-19 23:04:10 +10:00
"github.com/stretchr/testify/assert"
"github.com/alecthomas/chroma/lexers"
"github.com/alecthomas/chroma/styles"
)
func TestCompressStyle(t *testing.T) {
2017-09-18 14:19:59 +10:00
style := "color: #888888; background-color: #faffff"
actual := compressStyle(style)
2017-09-18 14:19:59 +10:00
expected := "color:#888;background-color:#faffff"
2017-09-19 23:04:10 +10:00
assert.Equal(t, expected, actual)
}
func BenchmarkHTMLFormatter(b *testing.B) {
formatter := New()
writer, err := formatter.Format(ioutil.Discard, styles.Fallback)
assert.NoError(b, err)
b.ResetTimer()
for i := 0; i < b.N; i++ {
err = lexers.Go.Tokenise(nil, "package main\nfunc main()\n{\nprintln(`hello world`)\n}\n", writer)
assert.NoError(b, err)
}
}