summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/pelletier/go-toml/parser_test.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2018-01-29 14:17:40 -0800
committerGitHub <noreply@github.com>2018-01-29 14:17:40 -0800
commit961c04cae992eadb42d286d2f85f8a675bdc68c8 (patch)
tree3408f2d06f847e966c53485e2d54c692cdd037c1 /vendor/github.com/pelletier/go-toml/parser_test.go
parent8d66523ba7d9a77129844be476732ebfd5272d64 (diff)
downloadchat-961c04cae992eadb42d286d2f85f8a675bdc68c8.tar.gz
chat-961c04cae992eadb42d286d2f85f8a675bdc68c8.tar.bz2
chat-961c04cae992eadb42d286d2f85f8a675bdc68c8.zip
Upgrading server dependancies (#8154)
Diffstat (limited to 'vendor/github.com/pelletier/go-toml/parser_test.go')
-rw-r--r--vendor/github.com/pelletier/go-toml/parser_test.go63
1 files changed, 62 insertions, 1 deletions
diff --git a/vendor/github.com/pelletier/go-toml/parser_test.go b/vendor/github.com/pelletier/go-toml/parser_test.go
index 6c8eec6a3..ca29c442e 100644
--- a/vendor/github.com/pelletier/go-toml/parser_test.go
+++ b/vendor/github.com/pelletier/go-toml/parser_test.go
@@ -2,6 +2,7 @@ package toml
import (
"fmt"
+ "math"
"reflect"
"testing"
"time"
@@ -46,7 +47,7 @@ func assertTree(t *testing.T, tree *Tree, err error, ref map[string]interface{})
func TestCreateSubTree(t *testing.T) {
tree := newTree()
tree.createSubTree([]string{"a", "b", "c"}, Position{})
- tree.Set("a.b.c", "", false, 42)
+ tree.Set("a.b.c", 42)
if tree.Get("a.b.c") != 42 {
t.Fail()
}
@@ -72,6 +73,17 @@ func TestNumberInKey(t *testing.T) {
})
}
+func TestIncorrectKeyExtraSquareBracket(t *testing.T) {
+ _, err := Load(`[a]b]
+zyx = 42`)
+ if err == nil {
+ t.Error("Error should have been returned.")
+ }
+ if err.Error() != "(1, 4): unexpected token" {
+ t.Error("Bad error message:", err.Error())
+ }
+}
+
func TestSimpleNumbers(t *testing.T) {
tree, err := Load("a = +42\nb = -21\nc = +4.2\nd = -2.1")
assertTree(t, tree, err, map[string]interface{}{
@@ -82,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)})
@@ -208,6 +239,36 @@ func TestSpaceKey(t *testing.T) {
})
}
+func TestDoubleQuotedKey(t *testing.T) {
+ tree, err := Load(`
+ "key" = "a"
+ "\t" = "b"
+ "\U0001F914" = "c"
+ "\u2764" = "d"
+ `)
+ assertTree(t, tree, err, map[string]interface{}{
+ "key": "a",
+ "\t": "b",
+ "\U0001F914": "c",
+ "\u2764": "d",
+ })
+}
+
+func TestSingleQuotedKey(t *testing.T) {
+ tree, err := Load(`
+ 'key' = "a"
+ '\t' = "b"
+ '\U0001F914' = "c"
+ '\u2764' = "d"
+ `)
+ assertTree(t, tree, err, map[string]interface{}{
+ `key`: "a",
+ `\t`: "b",
+ `\U0001F914`: "c",
+ `\u2764`: "d",
+ })
+}
+
func TestStringEscapables(t *testing.T) {
tree, err := Load("a = \"a \\n b\"")
assertTree(t, tree, err, map[string]interface{}{