Protobuf: fixed bug in PRNG in native tests

This commit is contained in:
dsavvinov
2016-08-18 11:19:05 +03:00
parent a0099d5bb9
commit bbc121d9d2
2 changed files with 10 additions and 4 deletions
@@ -1134,14 +1134,15 @@ fun checkRepSerializationIdentity(msg: MessageRepeatedVarints): Int {
} }
} }
object Rng { object Rng {
var rngState = 0.6938893903907228 var rngState = 0.6938893903907228
val point = 762939453125 val point = 762939453125
fun rng(): Double { fun rng(): Double {
val res = rngState - rngState.toInt().toDouble()
rngState *= point.toDouble() rngState *= point.toDouble()
return res rngState -= rngState.toLong().toDouble()
return rngState
} }
} }
@@ -435,14 +435,15 @@ fun checkRepZZSerializationIdentity(msg: MessageRepeatedZigZag): Int {
} }
} }
object Rng { object Rng {
var rngState = 0.6938893903907228 var rngState = 0.6938893903907228
val point = 762939453125 val point = 762939453125
fun rng(): Double { fun rng(): Double {
val res = rngState - rngState.toInt().toDouble()
rngState *= point.toDouble() rngState *= point.toDouble()
return res rngState -= rngState.toLong().toDouble()
return rngState
} }
} }
@@ -544,3 +545,7 @@ fun testArraysOfDefaultValues(): Int {
val msg = MessageRepeatedZigZag.BuilderMessageRepeatedZigZag(intArr, longArr).build() val msg = MessageRepeatedZigZag.BuilderMessageRepeatedZigZag(intArr, longArr).build()
return checkRepZZSerializationIdentity(msg) return checkRepZZSerializationIdentity(msg)
} }
fun main(args: Array<String>) {
println(testRepZigZag())
}