X-Git-Url: http://git.osdn.net/view?p=bytom%2Fvapor.git;a=blobdiff_plain;f=vendor%2Fgithub.com%2Fpelletier%2Fgo-toml%2Fkeysparsing_test.go;fp=vendor%2Fgithub.com%2Fpelletier%2Fgo-toml%2Fkeysparsing_test.go;h=0000000000000000000000000000000000000000;hp=7aa4cd64a62acf1d825a0a7229a5b6cf50354ff0;hb=d09b7a78d44dc259725902b8141cdba0d716b121;hpb=ee01d543fdfe1fd0a4d548965c66f7923ea7b062 diff --git a/vendor/github.com/pelletier/go-toml/keysparsing_test.go b/vendor/github.com/pelletier/go-toml/keysparsing_test.go deleted file mode 100644 index 7aa4cd64..00000000 --- a/vendor/github.com/pelletier/go-toml/keysparsing_test.go +++ /dev/null @@ -1,70 +0,0 @@ -package toml - -import ( - "fmt" - "testing" -) - -func testResult(t *testing.T, key string, expected []string) { - parsed, err := parseKey(key) - t.Logf("key=%s expected=%s parsed=%s", key, expected, parsed) - if err != nil { - t.Fatal("Unexpected error:", err) - } - if len(expected) != len(parsed) { - t.Fatal("Expected length", len(expected), "but", len(parsed), "parsed") - } - for index, expectedKey := range expected { - if expectedKey != parsed[index] { - t.Fatal("Expected", expectedKey, "at index", index, "but found", parsed[index]) - } - } -} - -func testError(t *testing.T, key string, expectedError string) { - res, err := parseKey(key) - if err == nil { - t.Fatalf("Expected error, but succesfully parsed key %s", res) - } - if fmt.Sprintf("%s", err) != expectedError { - t.Fatalf("Expected error \"%s\", but got \"%s\".", expectedError, err) - } -} - -func TestBareKeyBasic(t *testing.T) { - testResult(t, "test", []string{"test"}) -} - -func TestBareKeyDotted(t *testing.T) { - testResult(t, "this.is.a.key", []string{"this", "is", "a", "key"}) -} - -func TestDottedKeyBasic(t *testing.T) { - testResult(t, "\"a.dotted.key\"", []string{"a.dotted.key"}) -} - -func TestBaseKeyPound(t *testing.T) { - testError(t, "hello#world", "invalid bare character: #") -} - -func TestQuotedKeys(t *testing.T) { - testResult(t, `hello."foo".bar`, []string{"hello", "foo", "bar"}) - testResult(t, `"hello!"`, []string{"hello!"}) - testResult(t, `"hello\tworld"`, []string{"hello\tworld"}) - testResult(t, `"\U0001F914"`, []string{"\U0001F914"}) - testResult(t, `"\u2764"`, []string{"\u2764"}) - - testResult(t, `hello.'foo'.bar`, []string{"hello", "foo", "bar"}) - testResult(t, `'hello!'`, []string{"hello!"}) - testResult(t, `'hello\tworld'`, []string{`hello\tworld`}) - - testError(t, `"\w"`, `invalid escape sequence \w`) - testError(t, `"\`, `unfinished escape sequence`) - testError(t, `"\t`, `mismatched quotes`) -} - -func TestEmptyKey(t *testing.T) { - testError(t, "", "empty key") - testError(t, " ", "empty key") - testResult(t, `""`, []string{""}) -}