mirror of
https://github.com/corda/corda.git
synced 2025-06-24 02:04:12 +00:00
Added core changes and docs required for simm valuation demo.
This commit is contained in:
7
core/src/main/kotlin/com/r3corda/core/math/Utils.kt
Normal file
7
core/src/main/kotlin/com/r3corda/core/math/Utils.kt
Normal file
@ -0,0 +1,7 @@
|
||||
package com.r3corda.core.math
|
||||
|
||||
import java.math.BigDecimal
|
||||
|
||||
fun Iterable<BigDecimal>.sum(): BigDecimal {
|
||||
return this.fold(BigDecimal.valueOf(0)) { a: BigDecimal, b: BigDecimal -> a + b }
|
||||
}
|
14
core/src/test/kotlin/com/r3corda/core/math/Utils.kt
Normal file
14
core/src/test/kotlin/com/r3corda/core/math/Utils.kt
Normal file
@ -0,0 +1,14 @@
|
||||
package com.r3corda.core.math
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
import org.junit.Assert.*
|
||||
import java.math.BigDecimal
|
||||
|
||||
class Utils {
|
||||
@Test
|
||||
fun sum() {
|
||||
val calculated = listOf(BigDecimal.valueOf(1.0), BigDecimal.valueOf(5.0)).sum()
|
||||
assert(calculated == BigDecimal.valueOf(6.0))
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user