Skip to content

Commit

Permalink
Add some tests for type casting with signs.
Browse files Browse the repository at this point in the history
The tests for sign-safety are added in this PR.

Author: hyukjinkwon <[email protected]>

Closes databricks#20 from HyukjinKwon/typecast-test.
  • Loading branch information
HyukjinKwon committed Dec 11, 2015
1 parent 4628b2f commit b1b4673
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/test/scala/com/databricks/spark/xml/util/TypeCastSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ class TypeCastSuite extends FunSuite {
assert(TypeCast.castTo("2015-01-01", DateType) == Date.valueOf("2015-01-01"))
}

test("Types with sign are cast correctly") {
assert(TypeCast.signSafeToInt("+10") == 10)
assert(TypeCast.signSafeToLong("-10") == -10)
assert(TypeCast.signSafeToFloat("1.00") == 1.0)
assert(TypeCast.signSafeToDouble("-1.00") == -1.0)
}

test("Types with sign are checked correctly") {
assert(TypeCast.isBoolean("true"))
assert(TypeCast.isLong("10"))
assert(TypeCast.isDouble("+10.1"))
}

test("Float and Double Types are cast correctly with Locale") {
val locale : Locale = new Locale("fr", "FR")
Locale.setDefault(locale)
Expand Down

0 comments on commit b1b4673

Please sign in to comment.