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
+20
View File
@@ -2,6 +2,7 @@ package toml
import (
"fmt"
"math"
"reflect"
"testing"
"time"
@@ -93,6 +94,25 @@ func TestSimpleNumbers(t *testing.T) {
})
}
func TestSpecialFloats(t *testing.T) {
tree, err := Load(`
normalinf = inf
plusinf = +inf
minusinf = -inf
normalnan = nan
plusnan = +nan
minusnan = -nan
`)
assertTree(t, tree, err, map[string]interface{}{
"normalinf": math.Inf(1),
"plusinf": math.Inf(1),
"minusinf": math.Inf(-1),
"normalnan": math.NaN(),
"plusnan": math.NaN(),
"minusnan": math.NaN(),
})
}
func TestHexIntegers(t *testing.T) {
tree, err := Load(`a = 0xDEADBEEF`)
assertTree(t, tree, err, map[string]interface{}{"a": int64(3735928559)})