代码拉取完成,页面将自动刷新
package core
import (
"strings"
"testing"
)
var testsGetColumn = []struct {
name string
idx int
}{
{"Id", 0},
{"Deleted", 0},
{"Caption", 0},
{"Code_1", 0},
{"Code_2", 0},
{"Code_3", 0},
{"Parent_Id", 0},
{"Latitude", 0},
{"Longitude", 0},
}
var table *Table
func init() {
table = NewEmptyTable()
var name string
for i := 0; i < len(testsGetColumn); i++ {
// as in Table.AddColumn func
name = strings.ToLower(testsGetColumn[i].name)
table.columnsMap[name] = append(table.columnsMap[name], &Column{})
}
}
func TestGetColumn(t *testing.T) {
for _, test := range testsGetColumn {
if table.GetColumn(test.name) == nil {
t.Error("Column not found!")
}
}
}
func TestGetColumnIdx(t *testing.T) {
for _, test := range testsGetColumn {
if table.GetColumnIdx(test.name, test.idx) == nil {
t.Errorf("Column %s with idx %d not found!", test.name, test.idx)
}
}
}
func BenchmarkGetColumnWithToLower(b *testing.B) {
for i := 0; i < b.N; i++ {
for _, test := range testsGetColumn {
if _, ok := table.columnsMap[strings.ToLower(test.name)]; !ok {
b.Errorf("Column not found:%s", test.name)
}
}
}
}
func BenchmarkGetColumnIdxWithToLower(b *testing.B) {
for i := 0; i < b.N; i++ {
for _, test := range testsGetColumn {
if c, ok := table.columnsMap[strings.ToLower(test.name)]; ok {
if test.idx < len(c) {
continue
} else {
b.Errorf("Bad idx in: %s, %d", test.name, test.idx)
}
} else {
b.Errorf("Column not found: %s, %d", test.name, test.idx)
}
}
}
}
func BenchmarkGetColumn(b *testing.B) {
for i := 0; i < b.N; i++ {
for _, test := range testsGetColumn {
if table.GetColumn(test.name) == nil {
b.Errorf("Column not found:%s", test.name)
}
}
}
}
func BenchmarkGetColumnIdx(b *testing.B) {
for i := 0; i < b.N; i++ {
for _, test := range testsGetColumn {
if table.GetColumnIdx(test.name, test.idx) == nil {
b.Errorf("Column not found:%s, %d", test.name, test.idx)
}
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。