-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better parse error handling #7
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
constants/constants.go
Outdated
@@ -13,3 +13,6 @@ const ( | |||
SectionUSPUT SectionID = 11 | |||
SectionUSPCT SectionID = 12 | |||
) | |||
|
|||
var SectionIDNames = []string{"ID0", "ID1", "tcfeu2", "gpp header", "ID4", "ID5", "uspv1", "uspnat", | |||
"uspca", "uspva", "uspco", "usput", "uspct"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO: It's a bit odd to see names set for the value 0 which is undefined. There are names for sections 1, 4, and 5 - but they're not supported by this library. Based on how the function is used, it's save to ignore values for which are not parsed.
How do you feel about using a map for supported sections?
var sectionNamesByID = map[int]string{
2: "tcfeu2",
3: "gpp header",
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me.
}, | ||
expectedError: []error{fmt.Errorf("error parsing GPP header, section identifiers: error reading an int offset value in a Range(Fibonacci) entry(1): error reading bit 4 of Integer(Fibonacci): expected 1 bit at bit 32, but the byte array was only 4 bytes long")}, | ||
}, | ||
"GPP-uspca-error": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice naming. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.