Improve quote policy #1567
|
@ -13,7 +13,7 @@ import (
|
||||||
|
|
||||||
func TestAlwaysQuoteTo(t *testing.T) {
|
func TestAlwaysQuoteTo(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
quoter = Quoter{'[', ']', AlwaysReverse}
|
quoter = Quoter{'[', ']', AlwaysReserve}
|
||||||
kases = []struct {
|
kases = []struct {
|
||||||
expected string
|
expected string
|
||||||
value string
|
value string
|
||||||
|
@ -84,7 +84,7 @@ func TestReversedQuoteTo(t *testing.T) {
|
||||||
|
|
||||||
func TestNoQuoteTo(t *testing.T) {
|
func TestNoQuoteTo(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
quoter = Quoter{'[', ']', AlwaysNoReverse}
|
quoter = Quoter{'[', ']', AlwaysNoReserve}
|
||||||
kases = []struct {
|
kases = []struct {
|
||||||
expected string
|
expected string
|
||||||
value string
|
value string
|
||||||
|
@ -117,19 +117,19 @@ func TestNoQuoteTo(t *testing.T) {
|
||||||
|
|
||||||
func TestJoin(t *testing.T) {
|
func TestJoin(t *testing.T) {
|
||||||
cols := []string{"f1", "f2", "f3"}
|
cols := []string{"f1", "f2", "f3"}
|
||||||
quoter := Quoter{'[', ']', AlwaysReverse}
|
quoter := Quoter{'[', ']', AlwaysReserve}
|
||||||
|
|
||||||
assert.EqualValues(t, "[a],[b]", quoter.Join([]string{"a", " b"}, ","))
|
assert.EqualValues(t, "[a],[b]", quoter.Join([]string{"a", " b"}, ","))
|
||||||
|
|
||||||
assert.EqualValues(t, "[f1], [f2], [f3]", quoter.Join(cols, ", "))
|
assert.EqualValues(t, "[f1], [f2], [f3]", quoter.Join(cols, ", "))
|
||||||
|
|
||||||
quoter.IsReverse = AlwaysNoReverse
|
quoter.IsReserved = AlwaysNoReserve
|
||||||
assert.EqualValues(t, "f1, f2, f3", quoter.Join(cols, ", "))
|
assert.EqualValues(t, "f1, f2, f3", quoter.Join(cols, ", "))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStrings(t *testing.T) {
|
func TestStrings(t *testing.T) {
|
||||||
cols := []string{"f1", "f2", "t3.f3"}
|
cols := []string{"f1", "f2", "t3.f3"}
|
||||||
quoter := Quoter{'[', ']', AlwaysReverse}
|
quoter := Quoter{'[', ']', AlwaysReserve}
|
||||||
|
|
||||||
quotedCols := quoter.Strings(cols)
|
quotedCols := quoter.Strings(cols)
|
||||||
assert.EqualValues(t, []string{"[f1]", "[f2]", "[t3].[f3]"}, quotedCols)
|
assert.EqualValues(t, []string{"[f1]", "[f2]", "[t3].[f3]"}, quotedCols)
|
||||||
|
@ -143,6 +143,6 @@ func TestTrim(t *testing.T) {
|
||||||
|
|
||||||
for src, dst := range kases {
|
for src, dst := range kases {
|
||||||
assert.EqualValues(t, src, CommonQuoter.Trim(src))
|
assert.EqualValues(t, src, CommonQuoter.Trim(src))
|
||||||
assert.EqualValues(t, dst, Quoter{'[', ']', AlwaysReverse}.Trim(src))
|
assert.EqualValues(t, dst, Quoter{'[', ']', AlwaysReserve}.Trim(src))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user