0.1.1-SNAPSHOT: storages, sync tools, docs
This commit is contained in:
1 parent
3e6c487601
commit
babc3933eb
24 files changed
+925
-52
No files matched your search
@@ -50,9 +50,10 @@ data class FoobarFP1(val bar: Int, val foo: Int, val other: Int = -1)
|
||||
sealed class SC1 {
|
||||
|
||||
@Serializable
|
||||
class Nested: SC1()
|
||||
class Nested : SC1()
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
class BipackEncoderTest {
|
||||
|
||||
@Serializable
|
||||
@@ -356,7 +357,7 @@ class BipackEncoderTest {
|
||||
@Test
|
||||
fun testInstant() {
|
||||
val x = Clock.System.now()
|
||||
println( BipackEncoder.encode(x).toDump() )
|
||||
println(BipackEncoder.encode(x).toDump())
|
||||
val y = BipackDecoder.decode<Instant>(BipackEncoder.encode(x))
|
||||
assertEquals(x.toEpochMilliseconds(), y.toEpochMilliseconds())
|
||||
}
|
||||
@@ -369,7 +370,7 @@ class BipackEncoderTest {
|
||||
@Fixed
|
||||
val i: UInt,
|
||||
@Fixed
|
||||
val li: ULong
|
||||
val li: ULong,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
@@ -380,20 +381,20 @@ class BipackEncoderTest {
|
||||
@Unsigned
|
||||
val i: UInt,
|
||||
@Unsigned
|
||||
val li: ULong
|
||||
val li: ULong,
|
||||
)
|
||||
|
||||
@Test
|
||||
fun vectors() {
|
||||
val x = UInts(7u, 64000.toUShort(), 66000u, 931127140399u);
|
||||
val p = BipackEncoder.encode(x);
|
||||
val x = UInts(7u, 64000.toUShort(), 66000u, 931127140399u)
|
||||
val p = BipackEncoder.encode(x)
|
||||
println(p.toDump())
|
||||
println(p.encodeToBase64Compact())
|
||||
val y = BipackDecoder.decode<UInts>(p)
|
||||
assertEquals(x, y)
|
||||
|
||||
val xv = VarUInts(7u, 64000.toUShort(), 66000u, 931127140399u);
|
||||
val pv = BipackEncoder.encode(xv);
|
||||
val xv = VarUInts(7u, 64000.toUShort(), 66000u, 931127140399u)
|
||||
val pv = BipackEncoder.encode(xv)
|
||||
println(pv.toDump())
|
||||
println(pv.encodeToBase64Compact())
|
||||
val yv = BipackDecoder.decode<VarUInts>(pv)
|
||||
@@ -405,7 +406,8 @@ class BipackEncoderTest {
|
||||
@Test
|
||||
fun testStrangeUnpack() {
|
||||
@Serializable
|
||||
data class SFoo(val code: Int,val s1: String?=null,val s2: String?=null)
|
||||
data class SFoo(val code: Int, val s1: String? = null, val s2: String? = null)
|
||||
|
||||
val z = BipackEncoder.encode(117)
|
||||
println(z.toDump())
|
||||
val sf = BipackDecoder.decode<SFoo>(z)
|
||||
@@ -413,9 +415,9 @@ class BipackEncoderTest {
|
||||
}
|
||||
|
||||
@Serializable
|
||||
enum class TU1 {
|
||||
N1, N2, N3, N4
|
||||
}
|
||||
enum class TU1 {
|
||||
N1, N2, N3, N4
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package net.sergeych.synctools
|
||||
|
||||
import net.sergeych.tools.AtomicCounter
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class AtomicCounterTest {
|
||||
@Test
|
||||
fun incrementAndDecrement() {
|
||||
val ac = AtomicCounter(7)
|
||||
assertEquals(7, ac.getAndIncrement())
|
||||
assertEquals(8, ac.value)
|
||||
assertEquals(9, ac.incrementAndGet())
|
||||
assertEquals(9, ac.value)
|
||||
|
||||
assertEquals(9, ac.getAndDecrement())
|
||||
assertEquals(8, ac.value)
|
||||
assertEquals(7, ac.decrementAndGet())
|
||||
assertEquals(7, ac.value)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user