summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Fuller <nfuller@google.com>2014-05-20 08:48:41 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-05-20 08:48:41 +0000
commit097a76c9aa42873ab8f9d6364b85584fbef98193 (patch)
tree91d066e32f651c683f4a499071efa457b1a72690
parent9f977fa97630092c831d52a15d24f87c7e87c876 (diff)
parent0e78f0642104c599abb9fd4fb24092a6afb25510 (diff)
downloadlibcore-097a76c9aa42873ab8f9d6364b85584fbef98193.zip
libcore-097a76c9aa42873ab8f9d6364b85584fbef98193.tar.gz
libcore-097a76c9aa42873ab8f9d6364b85584fbef98193.tar.bz2
am 0e78f064: Merge "Fix InetAddressTest"
* commit '0e78f0642104c599abb9fd4fb24092a6afb25510': Fix InetAddressTest
-rw-r--r--luni/src/test/java/libcore/java/net/InetAddressTest.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/luni/src/test/java/libcore/java/net/InetAddressTest.java b/luni/src/test/java/libcore/java/net/InetAddressTest.java
index c7617ab..4b656cc 100644
--- a/luni/src/test/java/libcore/java/net/InetAddressTest.java
+++ b/luni/src/test/java/libcore/java/net/InetAddressTest.java
@@ -49,13 +49,16 @@ public class InetAddressTest extends junit.framework.TestCase {
"1234",
"0", // Single out the deprecated form of the ANY address.
- // Hex.
+ // Hex. Not supported by Android but supported by the RI.
"0x1.0x2.0x3.0x4",
"0x7f.0x00.0x00.0x01",
"7f.0.0.1",
- // Octal.
- "0177.00.00.01", // Historically, this would have been interpreted as 127.0.0.1.
+ // Octal. Not supported by Android but supported by the RI. In the RI, if any of the numbers
+ // cannot be treated as a decimal the entire IP is interpreted differently, leading to
+ // "0177.00.00.01" -> 177.0.0.1, but "0177.0x0.00.01" -> 127.0.0.1.
+ // Android does not do this.
+ "0256.00.00.01", // Historically, this could have been interpreted as 174.0.0.1.
// Negative numbers.
"-1.0.0.1",
@@ -89,6 +92,9 @@ public class InetAddressTest extends junit.framework.TestCase {
} catch (IllegalArgumentException expected) {
}
+ // Android does not recognize Octal (leading 0) cases: they are treated as decimal.
+ assertEquals("/177.0.0.1", InetAddress.parseNumericAddress("0177.00.00.01").toString());
+
for (String invalid : INVALID_IPv4_NUMERIC_ADDRESSES) {
try {
InetAddress.parseNumericAddress(invalid);
@@ -121,6 +127,9 @@ public class InetAddressTest extends junit.framework.TestCase {
// Negative test
assertFalse(InetAddress.isNumeric("example.com"));
+ // Android does not handle Octal (leading 0) cases: they are treated as decimal.
+ assertTrue(InetAddress.isNumeric("0177.00.00.01")); // Interpreted as 177.0.0.1
+
for (String invalid : INVALID_IPv4_NUMERIC_ADDRESSES) {
assertFalse(invalid, InetAddress.isNumeric(invalid));
}