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/app/src/test/java/com/gyf/csams/ExampleUnitTest.kt

48 lines
1.0 KiB

package com.gyf.csams
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.gyf.csams.util.ApiResponse
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 testYear(){
repeat(10,{
println(it)
})
}
@Test
fun testCharRange(){
println(('A'..'D').map { "选项$it" })
}
}