Files
v2rayNG/V2rayNG/app/src/test/java/com/v2ray/ang/AngUnitTest.kt
Tamim Hossain 18c0143186 Upgrade project to new Android Studio template and migrate Java code to Kotlin (#3937)
### Summary
- Updated the project structure using the latest Android Studio template.
- Migrated portions of the codebase from Java to Kotlin for improved readability and maintainability.

### Details
- Refactored and reorganized files according to the new Android Studio project template to ensure compatibility with the latest project standards.
- Migrated key Java classes to Kotlin, adopting Kotlin idioms and improving type safety.
- Verified that core functionalities remain intact after migration and update.
- Removed redundant Java files and updated imports where necessary.

### Notes
- Further Kotlin migration may be needed as additional Java files are reviewed.
- Test thoroughly to confirm that all functionalities work as expected after these changes.
2024-11-15 13:42:46 +08:00

47 lines
1.6 KiB
Kotlin

package com.v2ray.ang
import com.v2ray.ang.util.Utils
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 AngUnitTest {
@Test
fun test_parseInt() {
assertEquals(Utils.parseInt("1234"), 1234)
}
@Test
fun test_isIpAddress() {
assertFalse(Utils.isIpAddress("114.113.112.266"))
assertFalse(Utils.isIpAddress("666.666.666.666"))
assertFalse(Utils.isIpAddress("256.0.0.0"))
assertFalse(Utils.isIpAddress("::ffff:127.0.0.0.1"))
assertFalse(Utils.isIpAddress("baidu.com"))
assertFalse(Utils.isIpAddress(""))
assertTrue(Utils.isIpAddress("127.0.0.1"))
assertTrue(Utils.isIpAddress("127.0.0.1:80"))
assertTrue(Utils.isIpAddress("0.0.0.0/0"))
assertTrue(Utils.isIpAddress("::1"))
assertTrue(Utils.isIpAddress("[::1]:80"))
assertTrue(Utils.isIpAddress("2605:2700:0:3::4713:93e3"))
assertTrue(Utils.isIpAddress("[2605:2700:0:3::4713:93e3]:80"))
assertTrue(Utils.isIpAddress("::ffff:192.168.173.22"))
assertTrue(Utils.isIpAddress("[::ffff:192.168.173.22]:80"))
assertTrue(Utils.isIpAddress("1::"))
assertTrue(Utils.isIpAddress("::"))
assertTrue(Utils.isIpAddress("::/0"))
assertTrue(Utils.isIpAddress("10.24.56.0/24"))
assertTrue(Utils.isIpAddress("2001:4321::1"))
assertTrue(Utils.isIpAddress("240e:1234:abcd:12::6666"))
assertTrue(Utils.isIpAddress("240e:1234:abcd:12::/64"))
}
}