simple test for WifiStateChangeService.formatIpAddress()

94f79a6438c7021db9c02003865c17f3a0da1718 made me want to be sure
This commit is contained in:
Hans-Christoph Steiner 2016-05-24 22:46:07 +02:00
parent 68375163f5
commit c947f24495
2 changed files with 21 additions and 1 deletions

View File

@ -229,7 +229,7 @@ public class WifiStateChangeService extends IntentService {
}
}
private String formatIpAddress(int ipAddress) {
static String formatIpAddress(int ipAddress) {
if (ipAddress == 0) {
return null;
}

View File

@ -0,0 +1,20 @@
package org.fdroid.fdroid.net;
import org.junit.Test;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class WifiStateChangeServiceTest {
@Test
public void testFormatIpAddress() throws UnknownHostException {
for (long i = Integer.MIN_VALUE; i <= Integer.MAX_VALUE; i += 98273) {
String ip = WifiStateChangeService.formatIpAddress((int) i);
InetAddress.getByName(ip);
}
InetAddress.getByName(WifiStateChangeService.formatIpAddress(Integer.MAX_VALUE));
InetAddress.getByName(WifiStateChangeService.formatIpAddress(Integer.MIN_VALUE));
InetAddress.getByName(WifiStateChangeService.formatIpAddress(0));
}
}