missing initial files + publishing
This commit is contained in:
1 parent
aaa8c436b0
commit
f429cfe418
25 files changed
+870
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import kotlinx.datetime.Instant
|
||||
import net.sergeych.crypto2.initCrypto
|
||||
import net.sergeych.utools.nowToSeconds
|
||||
import net.sergeych.utools.pack
|
||||
import net.sergeych.utools.unpack
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.time.Duration.Companion.microseconds
|
||||
|
||||
class PackTest {
|
||||
inline fun <reified T>check(x: T?) {
|
||||
assertEquals(x, unpack<T>(pack(x)))
|
||||
}
|
||||
@Test
|
||||
fun testNullPack() = runTest {
|
||||
initCrypto()
|
||||
val d = pack("Hello")
|
||||
assertEquals(6, d.size)
|
||||
check(1)
|
||||
check(2L)
|
||||
check(1.00)
|
||||
check("hello")
|
||||
check<String>(null)
|
||||
check<Long?>(null)
|
||||
}
|
||||
@Test
|
||||
fun testTimePack() = runTest {
|
||||
initCrypto()
|
||||
val t1 = nowToSeconds()
|
||||
val t2 = t1 + 1.microseconds
|
||||
assertEquals(t1, unpack<Instant>(pack(t2)))
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user