Fix unicode handling and add tests

We now also return an incomplete triple to aid in debugging - non-nil
error means that this is not usable except for manual examination.
This commit is contained in:
kortschak 2014-07-25 10:46:10 +09:30
parent 59e3d620a5
commit dc17ccae80
5 changed files with 79 additions and 10 deletions

View file

@ -76,8 +76,12 @@
action Error {
if p < len(data) {
return graph.Triple{}, fmt.Errorf("%v: unexpected rune %q at %d", ErrInvalid, data[p], p)
if r := data[p]; r < unicode.MaxASCII {
return triple, fmt.Errorf("%v: unexpected rune %q at %d", ErrInvalid, data[p], p)
} else {
return triple, fmt.Errorf("%v: unexpected rune %q (\\u%04x) at %d", ErrInvalid, data[p], data[p], p)
}
}
return graph.Triple{}, ErrIncomplete
return triple, ErrIncomplete
}
}%%