github.com/searKing/golang/go@v1.2.117/database/sql/placeholder_test.go (about) 1 // Copyright 2020 The searKing Author. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package sql_test 6 7 import ( 8 "testing" 9 10 "github.com/searKing/golang/go/database/sql" 11 "github.com/searKing/golang/go/strings" 12 ) 13 14 func TestExpandAsColumns(t *testing.T) { 15 table := []struct { 16 Q, R []string 17 }{ 18 { 19 Q: []string{`a`}, 20 R: []string{`a AS a`}, 21 }, 22 { 23 Q: []string{`a.b`}, 24 R: []string{`a.b AS a_b`}, 25 }, 26 { 27 Q: []string{`a.b1asdas`}, 28 R: []string{`a.b1asdas AS a_b1asdas`}, 29 }, 30 } 31 for i, test := range table { 32 qr := sql.ExpandAsColumns(test.Q...) 33 if !strings.SliceEqual(qr, test.R) { 34 t.Errorf("#%d. got %q, want %q", i, qr, test.R) 35 } 36 } 37 }