Added a few unit tests for kotlin operator examples.
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user