示例#1
0
func TestAttributesName(t *testing.T) {
	need_connection()
	p := new(Personne)
	attr := gouda.M(p).AttributesNames()
	names := []string{"Nom", "Id", "Age"}
	sort.StringArray(attr).Sort()
	sort.StringArray(names).Sort()
	if len(names) != len(attr) {
		t.Error("Attributes Names, found  size mismatch : " + fmt.Sprint(len(attr)) + " for " + fmt.Sprint(len(names)))
	}

	if !reflect.DeepEqual(names, attr) {
		t.Error("Can't find Attributes Names, found : " + fmt.Sprint(attr))
	}
	var pp Personne
	attr = gouda.M(pp).AttributesNames()
	sort.StringArray(attr).Sort()
	if len(names) != len(attr) {
		t.Error("Attributes Names, found  size mismatch : " + fmt.Sprint(len(attr)) + " for " + fmt.Sprint(len(names)))
	}

	if !reflect.DeepEqual(names, attr) {
		t.Error("Can't find Attributes Names, found : " + fmt.Sprint(attr))
	}
}
示例#2
0
文件: sortmain.go 项目: 8l/go-learn
func strings() {
	data := []string{"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"}
	a := sort.StringArray(data)
	sort.Sort(a)
	if !sort.IsSorted(a) {
		panic()
	}
}
示例#3
0
文件: dict.go 项目: gitreview/ampify
func SortedKeys(dict map[string]string) (keys []string) {
	keys = make([]string, len(dict))
	i := 0
	for key, _ := range dict {
		keys[i] = key
		i += 1
	}
	sort.StringArray(keys).Sort()
	return
}
示例#4
0
文件: dice.go 项目: zot/bills-tools
func dumpResults(totMargin int, margins map[string]map[int]int) {
	vec := vector.StringVector(make([]string, 0, 32))
	for k := range margins {
		vec.Push(k)
	}
	sort.StringArray(vec).Sort()
	for _, dice := range vec {
		println("Margins for", dice)
		dumpMargin(totMargin, margins[dice])
	}
}
示例#5
0
文件: gtpcmd.go 项目: Sh4pe/komoku
// List all commands, one by each line, sorted alphabetically
func gtplist_commands(obj *GTPObject) *GTPCommand {
	signature := []int{}
	f := func(object *GTPObject, params []interface{}) (result string, quit bool, err Error) {
		result = ""
		var cmdVector vector.StringVector
		for cmdName, _ := range obj.commands {
			cmdVector.Push(cmdName)
		}
		sort.SortStrings(sort.StringArray(cmdVector))
		result += cmdVector[0]
		for i := 1; i < cmdVector.Len(); i++ {
			result += "\n" + cmdVector.At(i)
		}
		return result, false, nil
	}
	return &GTPCommand{Signature: signature,
		Func: f,
	}
}