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
Add StringSubject.isEqualToIgnoreCase #181
Conversation
Sometimes you have to test for string equality while not caring about case sensitivity e.g. when you work with data coming from a case insensitive source (like MySQL with some collation). Includes unit tests.
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
I signed it! |
CLAs look good, thanks! |
Hi ooxi, We discussed this idea a long time ago (internally), and these are the notes I was able to dig up:
So I've got a job running right now to see how many callers we'd potentially have for this method...will get back to you. |
Of all the calls to String.equalsIgnoreCase(String) in google's code base, only 1.25% were being used in conjunction with JUnit's assertTrue/assertFalse, so I'm a bit skeptical about this feature... Can you explain a bit more about "MySQL with collation" and why it's case insensitive? |
A couple of applictions use database schemata with a case insensitive charset, for example OXID eShop (an e-commerce system using MySQL as database backend) or SAP Business One (a business management software using MSSQL as database backend). Both use text identifiers for object identification so if you want to check if order X references customer Y you have to check for "Y" in a case insensitive fashion. I can understand if this feature gets rejected because of naming or i18n issues. But when developing with a case insensitive source a feature like this sure has many use cases :) |
Thanks for that additional info. I'm gonna leave this FR open for now. If we get additional, substantial requests for this feature, we'll re-investigate. Thanks again! |
I think something like fuzzy Truth is the way forward here, if we decide this is worth doing. |
I did not know about fuzzy truth when posting this pull request. I will play around with it but it really looks like covering my usecase quite nicely while being much more general |
While Fuzzy Truth handles this problem quite nice it does not solve my use case since |
Right, Fuzzy Truth is a relatively new feature, and it's currently only for use with collections. By "way forward" I meant that adding similar functionality to |
@dimo414 I agree that enabling fuzzy test behavior injection into other subjects would not only solve my use case but be easily expandable and thus quite likely the right way forward |
Case-insensitive comparisons finally made Truth 0.41: |
Sometimes you have to test for string equality while not caring about case sensitivity e.g. when you work with data coming from a case insensitive source (like MySQL with some collation). Includes unit tests.
CLA will follow.