Exemplo n.º 1
0
func TestCreateData(t *testing.T) {
	conn := gouda.OpenXML(testFileName).(*gouda.XMLConnector)
	table := conn.CreateTable("personne")
	table.AddAttribute("nom", gouda.StringKind)
	table.AddAttribute("age", gouda.IntKind)
	//	fmt.Println(table)
	table.Insert(map[string]gouda.Value{"id": gouda.SysInt(1).Value(), "nom": gouda.SysString("toto").Value(), "age": gouda.SysInt(13).Value()})
	table.Insert(map[string]gouda.Value{"id": gouda.SysInt(2).Value(), "nom": gouda.SysString("titi").Value(), "age": gouda.SysInt(13).Value()})
	conn.Close()
	conn = gouda.OpenXML(testFileName).(*gouda.XMLConnector)
	if conn.Table("personne").Data().Len() != 2 {
		t.Error("Not Found 2 ")
	}
	conn.Close()
}
Exemplo n.º 2
0
func init_xml() {
	conStr := "personnes.xml"
	conn := gouda.OpenXML(conStr).(*gouda.XMLConnector)
	table := conn.CreateTable("personne")
	table.AddAttribute("nom", gouda.StringKind)
	table.AddAttribute("age", gouda.IntKind)
	table.Insert(map[string]gouda.Value{"id": gouda.SysInt(1).Value(), "nom": gouda.SysString("toto").Value(), "age": gouda.SysInt(13).Value()})
	table.Insert(map[string]gouda.Value{"id": gouda.SysInt(2).Value(), "nom": gouda.SysString("titi").Value(), "age": gouda.SysInt(0).Value()})
	table = conn.CreateTable("cars")
	table.AddAttribute("plate", gouda.StringKind)
	table.AddAttribute("model", gouda.StringKind)
	table.AddAttribute("owner_id", gouda.IntKind)
	table.Insert(map[string]gouda.Value{"id": gouda.SysInt(1).Value(), "plate": gouda.SysString("123ABC12").Value(), "model": gouda.SysString("Renault").Value(), "owner_id": gouda.SysInt(1).Value()})
	conn.Close()
	conn2 := gouda.OpenXML(conStr)
	gouda.GetConnectionStore().RegisterConnection(&conn2)

}
Exemplo n.º 3
0
func TestStringValue(t *testing.T) {
	f := gouda.SysString("toto").Value()
	if f.String() != "toto" {
		t.Error("Failed to recover toto")
	}
	f.SetString("titi")
	if f.String() != "titi" {
		t.Error("Failed to recover titi")
	}
	if f.Kind() != gouda.StringKind {
		t.Error("Not of StringKind")
	}
	//	fmt.Printf("%#v\n",f)
}