Protobuf: fixed bug in PRNG in native tests
This commit is contained in:
@@ -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())
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user