Fixes #272.
R=rsc
https://golang.org/cl/161061
return c == '"' || c == '[' || c == ']' || c == ':' || c == '{' || c == '}' || c == ','
}
-func white(c byte) bool { return c == ' ' || c == '\t' || c == '\n' || c == '\v' }
+func white(c byte) bool { return c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\v' }
func skipwhite(p string, i int) int {
for i < len(p) && white(p[i]) {
}
}
+const whiteSpaceEncoded = " \t{\n\"s\"\r:\"string\"\v}"
+
+func TestUnmarshalWhitespace(t *testing.T) {
+ var m myStruct;
+ ok, errtok := Unmarshal(whiteSpaceEncoded, &m);
+ if !ok {
+ t.Fatalf("Unmarshal failed near %s", errtok)
+ }
+ check(t, m.S == "string", "string", m.S);
+}
+
func TestUnmarshal(t *testing.T) {
var m myStruct;
m.F = true;