Add support for special float values (inf and nan) (#210)

This commit is contained in:
Jelte Fennema
2018-01-18 23:10:55 +01:00
committed by Thomas Pelletier
parent a1e8a8d702
commit 778c285afa
6 changed files with 79 additions and 2 deletions
+18
View File
@@ -309,6 +309,24 @@ func TestTreeWriteToFloat(t *testing.T) {
}
}
func TestTreeWriteToSpecialFloat(t *testing.T) {
expected := `a = +inf
b = -inf
c = nan`
tree, err := Load(expected)
if err != nil {
t.Fatal(err)
}
str, err := tree.ToTomlString()
if err != nil {
t.Fatal(err)
}
if strings.TrimSpace(str) != strings.TrimSpace(expected) {
t.Fatalf("Expected:\n%s\nGot:\n%s", expected, str)
}
}
func BenchmarkTreeToTomlString(b *testing.B) {
toml, err := Load(sampleHard)
if err != nil {