Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@

package org.apache.spark.sql.types.decimal

import org.apache.spark.SparkFunSuite
import org.apache.spark.sql.types.Decimal
import scala.language.postfixOps

import org.scalacheck.Prop.forAll
import org.scalatest.PrivateMethodTester
import org.scalatest.prop.Checkers

import scala.language.postfixOps
import org.apache.spark.SparkFunSuite
import org.apache.spark.sql.types.Decimal

class DecimalSuite extends SparkFunSuite with PrivateMethodTester {
class DecimalSuite extends SparkFunSuite with PrivateMethodTester with Checkers {
test("creating decimals") {
/** Check that a Decimal has the given string representation, precision and scale */
def checkDecimal(d: Decimal, string: String, precision: Int, scale: Int): Unit = {
Expand Down Expand Up @@ -53,6 +56,12 @@ class DecimalSuite extends SparkFunSuite with PrivateMethodTester {
intercept[IllegalArgumentException](Decimal(1e17.toLong, 17, 0))
}

test("SPARK-8802: Decimal.apply(x: BigDecimal).toBigDecimal === x") {
val x = BigDecimal(BigInt("18889465931478580854784"), -2147483648)
assert(Decimal(x).toBigDecimal === x)
check(forAll((d: BigDecimal) => Decimal(d).toBigDecimal === d))
}

test("double and long values") {
/** Check that a Decimal converts to the given double and long values */
def checkValues(d: Decimal, doubleValue: Double, longValue: Long): Unit = {
Expand Down