Support byte order mark (#253)

Fixes #250
This commit is contained in:
Thomas Pelletier
2018-11-23 19:15:58 -05:00
committed by GitHub
parent b56e1b27b4
commit 539dd095b3
2 changed files with 49 additions and 0 deletions
+20
View File
@@ -104,3 +104,23 @@ func TestTomlFromMap(t *testing.T) {
t.Fatal("hello should be 42, not", tree.Get("hello"))
}
}
func TestLoadBytesBOM(t *testing.T) {
payloads := [][]byte{
[]byte("\xFE\xFFhello=1"),
[]byte("\xFF\xFEhello=1"),
[]byte("\xEF\xBB\xBFhello=1"),
[]byte("\x00\x00\xFE\xFFhello=1"),
[]byte("\xFF\xFE\x00\x00hello=1"),
}
for _, data := range payloads {
tree, err := LoadBytes(data)
if err != nil {
t.Fatal("unexpected error:", err, "for:", data)
}
v := tree.Get("hello")
if v != int64(1) {
t.Fatal("hello should be 1, not", v)
}
}
}