Fix unit tests
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
package com.github.shadowsocks;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() throws Exception {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
||||
|
||||
assertEquals("com.github.shadowsocks", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,6 @@ class AclTest {
|
||||
private const val INPUT1 = """[proxy_all]
|
||||
[bypass_list]
|
||||
1.0.1.0/24
|
||||
[proxy_list]
|
||||
(^|\.)4tern\.com${'$'}
|
||||
"""
|
||||
}
|
||||
|
||||
@@ -30,7 +30,8 @@ class Subnet(val address: InetAddress, val prefixSize: Int) : Comparable<Subnet>
|
||||
val parts = (value as java.lang.String).split("/", 2)
|
||||
val addr = parts[0].parseNumericAddress() ?: return null
|
||||
return if (parts.size == 2) try {
|
||||
Subnet(addr, parts[1].toInt())
|
||||
val prefixSize = parts[1].toInt()
|
||||
if (prefixSize < 0 || prefixSize > addr.address.size shl 3) null else Subnet(addr, prefixSize)
|
||||
} catch (_: NumberFormatException) {
|
||||
null
|
||||
} else Subnet(addr, addr.address.size shl 3)
|
||||
|
||||
Reference in New Issue
Block a user