1
0
Fork 0

Add tests for TextFormatter

This commit is contained in:
Daniele Tricoli 2015-12-08 00:42:12 +01:00
parent 593de41093
commit 6abc82a825
1 changed files with 29 additions and 0 deletions

View File

@ -3,6 +3,8 @@ import (
"strconv"
"testing"
"eriol.xyz/piken/sql"
"github.com/stretchr/testify/assert"
)
@ -17,3 +19,30 @@ func TestCodePointToGlyph(t *testing.T) {
assert.Equal(t, err.(*strconv.NumError).Err, strconv.ErrRange)
}
}
func TestFormat(t *testing.T) {
s := sql.UnicodeData{CodePoint: "1F602",
Name: "FACE WITH TEARS OF JOY"}
formatter := NewTextFormatter(
[]string{"CodePoint", "Name"}, " -- ", true)
b, _ := formatter.Format(&s)
assert.Equal(t, b, "1F602 -- FACE WITH TEARS OF JOY -- 😂")
formatter = NewTextFormatter(
[]string{"CodePoint", "Name"}, " ## ", true)
b, _ = formatter.Format(&s)
assert.Equal(t, b, "1F602 ## FACE WITH TEARS OF JOY ## 😂")
formatter = NewTextFormatter(
[]string{"Name"}, " -- ", true)
b, _ = formatter.Format(&s)
assert.Equal(t, b, "FACE WITH TEARS OF JOY -- 😂")
formatter = NewTextFormatter(
[]string{"Name"}, " -- ", false)
b, _ = formatter.Format(&s)
assert.Equal(t, b, "FACE WITH TEARS OF JOY")
}