package ini import "testing" func TestParseSectionsAndPairs(t *testing.T) { in := []byte(` # a comment lectionary = new ; trailing comment [assumption] date = 08-15 name.pl = Wniebowzięcie ; unicode ok rank= solemnity [assumption/vigil] reading.gospel = Łk 11,27-28 `) secs, err := Parse(in) if err != nil { t.Fatal(err) } // top-level pairs land in a section with empty name, first. if secs[0].Name != "" || len(secs[0].Pairs) != 1 || secs[0].Pairs[0] != (Pair{"lectionary", "new"}) { t.Fatalf("top-level = %+v", secs[0]) } if secs[1].Name != "assumption" || secs[1].Pairs[1] != (Pair{"name.pl", "Wniebowzięcie"}) { t.Fatalf("assumption = %+v", secs[1]) } if secs[1].Pairs[2] != (Pair{"rank", "solemnity"}) { t.Fatalf("no-space key = %+v", secs[1].Pairs[2]) } if secs[2].Name != "assumption/vigil" { t.Fatalf("subsection = %q", secs[2].Name) } } func TestList(t *testing.T) { got := List("bt, wuj ,, vul") want := []string{"bt", "wuj", "vul"} if len(got) != len(want) { t.Fatalf("List = %v", got) } for i := range want { if got[i] != want[i] { t.Fatalf("List[%d] = %q want %q", i, got[i], want[i]) } } }