Closed rioderelfte closed 8 years ago
Thanks for this. That was a bit of a schoolboy error on my part! I'll try and merge this this evening - and port over to Catch too (I see your comments there).
:scream: This is horrendous. I mean both the original code, and this patch only fixing indices while keeping that awfully obfuscated code in place.
@ianmacs showed what these tests actually do in Catch comment: https://github.com/philsquared/Catch/issues/665#issuecomment-224564469 That's what a proper fix would look like.
On reflection I tend to agree with you, @lightmare! Not sure why I did it that way to start with (I think the fact there were more separators - with the possibility of more still - made a "find" based approach attractive - but the embedded nulls required the fragile string length in there. You're right: horrendous really!)
I could have my cake and eat it by making the string literal a global and using sizeof
on it, but I don't think it's worth it here. I'll consider using something like @ianmacs approach.
Thanks for calling me out on it!
I think the fact there were more separators - with the possibility of more still - made a "find" based approach attractive - but the embedded nulls required the fragile string length in there.
I see. Tip: next time you need to do that kind of "find" including '\0'
, you can use good ol' strchr
;)
Hmm... it would work (and is less brittle). Not sure I like it, though.
The string literal was changed without changing the length of the string given to the constructor.
This causes all my Catch tests to fail when built using AddressSanitizer.