Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
9352f2df
Commit
9352f2df
authored
Dec 14, 2017
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix SubnetTest
parent
9a2643ec
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
26 deletions
+12
-26
mobile/src/main/java/com/github/shadowsocks/utils/Utils.kt
mobile/src/main/java/com/github/shadowsocks/utils/Utils.kt
+11
-7
mobile/src/test/java/com/github/shadowsocks/ExampleUnitTest.kt
...e/src/test/java/com/github/shadowsocks/ExampleUnitTest.kt
+0
-17
mobile/src/test/java/com/github/shadowsocks/utils/SubnetTest.kt
.../src/test/java/com/github/shadowsocks/utils/SubnetTest.kt
+1
-2
No files found.
mobile/src/main/java/com/github/shadowsocks/utils/Utils.kt
View file @
9352f2df
...
...
@@ -7,7 +7,6 @@ import android.os.Build
import
android.support.v4.app.Fragment
import
android.support.v4.app.FragmentManager
import
android.support.v7.util.SortedList
import
android.util.TypedValue
import
com.github.shadowsocks.App.Companion.app
import
java.lang.reflect.InvocationTargetException
import
java.net.InetAddress
...
...
@@ -15,7 +14,11 @@ import java.net.URLConnection
private
val
isNumericMethod
by
lazy
{
InetAddress
::
class
.
java
.
getMethod
(
"isNumeric"
,
String
::
class
.
java
)
}
private
val
parseNumericAddressMethod
by
lazy
{
try
{
InetAddress
::
class
.
java
.
getMethod
(
"parseNumericAddress"
,
String
::
class
.
java
)
}
catch
(
_
:
NoSuchMethodException
)
{
null
}
}
private
val
fieldChildFragmentManager
by
lazy
{
val
field
=
Fragment
::
class
.
java
.
getDeclaredField
(
"mChildFragmentManager"
)
...
...
@@ -24,11 +27,12 @@ private val fieldChildFragmentManager by lazy {
}
fun
String
.
isNumericAddress
():
Boolean
=
isNumericMethod
.
invoke
(
null
,
this
)
as
Boolean
fun
String
.
parseNumericAddress
():
InetAddress
=
try
{
parseNumericAddressMethod
.
invoke
(
null
,
this
)
as
InetAddress
}
catch
(
exc
:
InvocationTargetException
)
{
fun
String
.
parseNumericAddress
():
InetAddress
=
if
(
parseNumericAddressMethod
==
null
)
InetAddress
.
getByName
(
this
)
else
try
{
parseNumericAddressMethod
!!
.
invoke
(
null
,
this
)
as
InetAddress
}
catch
(
exc
:
InvocationTargetException
)
{
throw
exc
.
cause
?:
exc
}
}
fun
parsePort
(
str
:
String
?,
default
:
Int
,
min
:
Int
=
1025
):
Int
{
val
x
=
str
?.
toIntOrNull
()
?:
default
...
...
mobile/src/test/java/com/github/shadowsocks/ExampleUnitTest.kt
deleted
100644 → 0
View file @
9a2643ec
package
com.github.shadowsocks
import
org.junit.Test
import
org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see [Testing documentation](http://d.android.com/tools/testing)
*/
class
ExampleUnitTest
{
@Test
fun
addition_isCorrect
()
{
assertEquals
(
4
,
(
2
+
2
).
toLong
())
}
}
\ No newline at end of file
mobile/src/test/java/com/github/shadowsocks/utils/SubnetTest.kt
View file @
9352f2df
package
com.github.shadowsocks.utils
import
com.github.shadowsocks.utils.Subnet
import
org.junit.Assert
import
org.junit.Test
import
java.net.InetAddress
object
SubnetTest
{
class
SubnetTest
{
@Test
fun
parsingAndEquals
()
{
Assert
.
assertEquals
(
Subnet
(
InetAddress
.
getByName
(
"1.10.11.12"
),
25
),
Subnet
.
fromString
(
"1.10.11.12/25"
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment