Added a few unit tests for kotlin operator examples.

This commit is contained in:
Ali Dehghani
2018-11-29 13:30:52 +03:30
parent 1250605e19
commit ad8ae556a8
6 changed files with 85 additions and 1 deletions
@@ -1,3 +1,5 @@
package com.baeldung.operators
import java.math.BigDecimal
enum class Currency {
@@ -1,3 +1,5 @@
package com.baeldung.operators
interface Page<T> {
fun pageNumber(): Int
fun pageSize(): Int
@@ -1,3 +1,5 @@
package com.baeldung.operators
data class Point(val x: Int, val y: Int)
operator fun Point.unaryMinus() = Point(-x, -y)
@@ -14,7 +16,7 @@ operator fun Point.times(factor: Int): Point = Point(x * factor, y * factor)
operator fun Int.times(point: Point): Point = Point(point.x * this, point.y * this)
class Shape {
private val points = mutableListOf<Point>()
val points = mutableListOf<Point>()
operator fun Point.unaryPlus() {
points.add(this)
@@ -1,3 +1,5 @@
package com.baeldung.operators
import java.math.BigInteger
operator fun <T> MutableCollection<T>.plusAssign(element: T) {