[ISSUES-3063][Improve] Improve ImplicitsUtilsTest test code coverage (#3558)
diff --git a/streampark-common/src/test/scala/org/apache/streampark/common/util/ImplicitsUtilsTest.scala b/streampark-common/src/test/scala/org/apache/streampark/common/util/ImplicitsUtilsTest.scala
index 04a22d9..7b77e92 100644
--- a/streampark-common/src/test/scala/org/apache/streampark/common/util/ImplicitsUtilsTest.scala
+++ b/streampark-common/src/test/scala/org/apache/streampark/common/util/ImplicitsUtilsTest.scala
@@ -41,19 +41,29 @@
}
test("StringImplicits.cast should convert string to the specified type") {
+ val byteString = "1"
val intString = "123"
val doubleString = "3.14"
+ val floatString = "3.14f"
val booleanString = "true"
+ val shortString = "12345"
+ val longString = "100000000"
+ assert(booleanString.cast[Boolean](classOf[Boolean]))
+ assert(byteString.cast[Byte](classOf[Byte]) == 1)
assert(intString.cast[Int](classOf[Int]) == 123)
assert(doubleString.cast[Double](classOf[Double]) == 3.14)
- assert(booleanString.cast[Boolean](classOf[Boolean]))
+ assert(floatString.cast[Float](classOf[Float]) == 3.14f)
+ assert(shortString.cast[Short](classOf[Short]) == 12345)
+ assert(longString.cast[Long](classOf[Long]) == 100000000)
}
test("StringImplicits.cast should throw IllegalArgumentException for unsupported type") {
val unsupportedString = "test"
+ val unsupportedBigdeciaml = "10e5"
assertThrows[IllegalArgumentException] {
unsupportedString.cast[Unit](classOf[Unit])
+ unsupportedBigdeciaml.cast[BigDecimal](classOf[BigDecimal])
}
}
}