1
0
Fork 0

Add tests for TextFormatter

main
Daniele Tricoli 7 years ago
parent 593de41093
commit 6abc82a825
  1. 29
      format/text_test.go

@ -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")
}

Loading…
Cancel
Save