I know it's weird, but this is what I have.
I'm writing a unit test to check my logic for an Android application. During the test execution, I see that it fails on that line:
if (!TextUtils.isEmpty(fromFile))
Before that if
statement fromFile is equals to ""
(empty string), but somehow it passes over it and breaks with another logic that doesn't expect empty string.
Diving into debug I saw that fromFile.isEmpty()
returns correct result, but TextUtils.isEmpty(fromFile)
says that it's not empty.
Open source code, i see:
public static boolean isEmpty(@Nullable CharSequence str) {
if (str == null || str.length() == 0)
return true;
else
return false;
}
and String.java:
public boolean isEmpty() {
return value.length == 0;
}
I have following configutation: jdk 1.8.0_77
I would like to avoid whole logic in the app to support String.isEmpty() just to pass the test, since I need to support code before Android API 9, where String.isEmpty
is not available, and also TextUtils.isEmpty()
do more.
Any help with clarification and suggesttions would be helpful.
Has anyone faced it? How should I fix it? Thanks in advance!