This is an archive of the discontinued LLVM Phabricator instance.

Add unit tests for StringSwitch.
ClosedPublic

Authored by zturner on Oct 3 2016, 11:34 AM.

Details

Summary

Adds unit tests for Case, Cases, StartsWith, and EndsWith with a variety of different argument types.

Diff Detail

Repository
rL LLVM

Event Timeline

zturner updated this revision to Diff 73311.Oct 3 2016, 11:34 AM
zturner retitled this revision from to Add unit tests for StringSwitch..
zturner updated this object.
zturner added a reviewer: chandlerc.
zturner added a subscriber: llvm-commits.

I'll hold off on uploading the other patches, since how I write the tests for the lower versions depends on what your comments are on this patch.

chandlerc accepted this revision.Oct 3 2016, 11:54 AM
chandlerc edited edge metadata.

I was all prepared to not like this approach for testing. But it looks really, really nice. I've got nothing to really suggest here other than some test cases you should probably add:

  • purely length-delimited cases.
  • edge cases with '\0' bytes in the middle of the string
    • '\0' in the middle of the case
    • '\0' in the middle of the input

For the latter: I think the formation of the StringRef will handle all of this and you'll just show that whatever length the StringRef has, that's the length that is used. But good to document this fact so folks don't go and switch the code to use strncmp for some weird reason.

Feel free to submit with whatever you come up with here.

This revision is now accepted and ready to land.Oct 3 2016, 11:54 AM
This revision was automatically updated to reflect the committed changes.