-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If string is empty return empty string instead of null
Verify that passing in an empty string does not return null Handling cases where the url could be malformed so there are no hosts even with a non-empty string
- Loading branch information
Showing
2 changed files
with
27 additions
and
4 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
WordPressUtils/src/androidTest/java/org/wordpress/android/util/UrlUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.wordpress.android.util; | ||
|
||
import android.test.InstrumentationTestCase; | ||
|
||
public class UrlUtilsTest extends InstrumentationTestCase { | ||
public void testGetDomainFromUrlWithEmptyStringDoesNotReturnNull() { | ||
assertNotNull(UrlUtils.getDomainFromUrl("")); | ||
} | ||
|
||
public void testGetDomainFromUrlWithNoHostDoesNotReturnNull() { | ||
assertNotNull(UrlUtils.getDomainFromUrl("wordpress")); | ||
} | ||
|
||
public void testGetDomainFromUrlWithHostReturnsHost() { | ||
String url = "http://www.wordpress.com"; | ||
String host = UrlUtils.getDomainFromUrl(url); | ||
|
||
assertTrue(host.equals("www.wordpress.com")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters