Exemple #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))
	}
}
Exemple #2
0
func strings() {
	data := []string{"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"}
	a := sort.StringArray(data)
	sort.Sort(a)
	if !sort.IsSorted(a) {
		panic()
	}
}
Exemple #3
0
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
}
Exemple #4
0
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])
	}
}
Exemple #5
0
// 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,
	}
}