Add tests for TextFormatter
This commit is contained in:
parent
593de41093
commit
6abc82a825
|
@ -3,6 +3,8 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"eriol.xyz/piken/sql"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,3 +19,30 @@ func TestCodePointToGlyph(t *testing.T) {
|
||||||
assert.Equal(t, err.(*strconv.NumError).Err, strconv.ErrRange)
|
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…
Reference in a new issue