You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
csamsclient/foreground/src/test/java/com/gyf/csams/ExampleUnitTest.kt

55 lines
1.2 KiB

package com.gyf.csams
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.gyf.csams.util.ApiResponse
import com.gyf.csams.util.randomChinese
import com.gyf.lib.uikit.TestLib
import org.junit.Assert.assertEquals
import org.junit.Test
/**
* 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)
}
data class Fuck(val name:String)
@Test
fun testGson(){
// val e="{\"code\":200,\"message\":\"学号可注册\",\"body\":false}"
val c=ApiResponse(code = 200,message = "aaa",body= null)
val d=Gson().toJson(c)
println(d)
val e=Gson().fromJson<ApiResponse<Boolean>>(d,object : TypeToken<ApiResponse<Boolean>>() {}.type)
println(e.body)
}
@Test
fun testCharRange() {
repeat(100) {
println(randomChinese())
}
// println(java.time.format.DateTimeFormatter.ISO_INSTANT
// .format(java.time.Instant.ofEpochMilli(1532358895000)))
}
@Test
fun testLib() {
TestLib.hello()
Fuck()
}
}