committed by
Thomas Pelletier
parent
878c11e70e
commit
a410399d2c
+15
-1
@@ -22,7 +22,10 @@ func testResult(t *testing.T, key string, expected []string) {
|
||||
}
|
||||
|
||||
func testError(t *testing.T, key string, expectedError string) {
|
||||
_, err := parseKey(key)
|
||||
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)
|
||||
}
|
||||
@@ -47,6 +50,17 @@ func TestBaseKeyPound(t *testing.T) {
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user