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() }
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) }
func TestIntValue(t *testing.T) { f := gouda.SysInt(12).Value() if f.Int() != 12 { t.Error("Failed to recover 12") } f.SetInt(13) if f.Int() != 13 { t.Error("Failed to recover 13") } if f.Kind() != gouda.IntKind { t.Error("Not of IntKind") } // fmt.Printf("%#v\n",f) }