Contextful validity errors, null-byte specs fix - #9
Conversation
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
20a958c to
b5ec11a
Compare
|
Based on GitHub Actions benchmarks, It would be nice to have some tests for invalid inputs, maybe even checking the position (although that might be overkill). |
b5ec11a to
124dee0
Compare
type InvalidRuneError struct {
Rune rune
Position int
} |
I think this change would almost exclusively be used for tests, so I'm not too sure. I was originally thinking parsing the error string for the reported position and checking if it matches what is expected (hence me calling it overkill). |
nihaals
left a comment
There was a problem hiding this comment.
I think we should add the position to InvalidRuneError and add tests for invalid inputs, also checking the position to ensure it matches.
Do you have a set of reference invalid inputs? |
A few examples:
|
This pull request adds meaningful errors while decoding as well as proper null-byte encoding.
Benchmarks
New is the pull request and old is
upstream/main. Test performed on a laptop with an Intel Core i5-8250U.The performance loss in
DecodeFromis probablyscanner.Text()having to allocate a new string for each chunk. The speed is still fairly decent, though.