Commit 40688911 authored by Mygod's avatar Mygod

Add unit test for Subnet matching

parent ff039d5c
package com.github.shadowsocks.net
import android.net.InetAddresses.parseNumericAddress
import org.junit.Assert
import org.junit.Test
import java.net.InetAddress
......@@ -25,4 +26,12 @@ class SubnetTest {
Assert.assertEquals(null, Subnet.fromString("caec:cec6:c4ef:bb7b:1a78:d055:216d:3a78/-99"))
Assert.assertEquals(null, Subnet.fromString("caec:cec6:c4ef:bb7b:1a78:d055:216d:3a78/1/0"))
}
@Test
fun matching() {
val matcher = Subnet.fromString("1.10.11.12/25")!!.toImmutable()
Assert.assertFalse(matcher.matches(parseNumericAddress("1.10.10.12").address))
Assert.assertTrue(matcher.matches(parseNumericAddress("1.10.11.13").address))
Assert.assertFalse(matcher.matches(parseNumericAddress("1.10.11.212").address))
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment