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.
36 lines
860 B
36 lines
860 B
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)
|
|
}
|
|
|
|
}
|
|
|
|
|