Add support for special float values (inf and nan) (#210)
This commit is contained in:
committed by
Thomas Pelletier
parent
a1e8a8d702
commit
778c285afa
@@ -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)})
|
||||
|
||||
Reference in New Issue
Block a user