Commit b25e9a09 authored by Mygod's avatar Mygod

Fix unit tests

parent 922eb8b2
...@@ -21,6 +21,6 @@ public class ExampleInstrumentedTest { ...@@ -21,6 +21,6 @@ public class ExampleInstrumentedTest {
// Context of the app under test. // Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext(); Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.github.shadowsockscorelibraries.test", appContext.getPackageName()); assertEquals("com.github.shadowsocks.core.test", appContext.getPackageName());
} }
} }
...@@ -22,6 +22,7 @@ android { ...@@ -22,6 +22,7 @@ android {
targetSdkVersion rootProject.sdkVersion targetSdkVersion rootProject.sdkVersion
versionCode 201 versionCode 201
versionName "4.4.1" versionName "4.4.1"
testApplicationId "com.github.shadowsocks.test"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary true vectorDrawables.useSupportLibrary true
resConfigs "fa", "ja", "ko", "ru", "zh-rCN", "zh-rTW" resConfigs "fa", "ja", "ko", "ru", "zh-rCN", "zh-rTW"
......
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 { ...@@ -28,7 +28,6 @@ class AclTest {
private const val INPUT1 = """[proxy_all] private const val INPUT1 = """[proxy_all]
[bypass_list] [bypass_list]
1.0.1.0/24 1.0.1.0/24
[proxy_list]
(^|\.)4tern\.com${'$'} (^|\.)4tern\.com${'$'}
""" """
} }
......
...@@ -30,7 +30,8 @@ class Subnet(val address: InetAddress, val prefixSize: Int) : Comparable<Subnet> ...@@ -30,7 +30,8 @@ class Subnet(val address: InetAddress, val prefixSize: Int) : Comparable<Subnet>
val parts = (value as java.lang.String).split("/", 2) val parts = (value as java.lang.String).split("/", 2)
val addr = parts[0].parseNumericAddress() ?: return null val addr = parts[0].parseNumericAddress() ?: return null
return if (parts.size == 2) try { 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) { } catch (_: NumberFormatException) {
null null
} else Subnet(addr, addr.address.size shl 3) } else Subnet(addr, addr.address.size shl 3)
......
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