You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2026/06/13 12:07:00 UTC
(commons-lang) 02/07: Refactor NumberUtilsTest.testCreateFloatFailure() test using @ParameterizedTest
This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
commit 947e1d61888e097e3356c32ba474248b6dd57327
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Jun 13 12:02:53 2026 +0000
Refactor NumberUtilsTest.testCreateFloatFailure() test using
@ParameterizedTest
---
.../org/apache/commons/lang3/math/NumberUtilsTest.java | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
index 39eb71e8c..234ef9a0f 100644
--- a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
@@ -537,13 +537,17 @@ protected void testCreateDoubleFailure(final String str) {
void testCreateFloat() {
assertEquals(Float.valueOf("1234.5"), NumberUtils.createFloat("1234.5"), "createFloat(String) failed");
assertNull(NumberUtils.createFloat(null), "createFloat(null) failed");
- testCreateFloatFailure("");
- testCreateFloatFailure(" ");
- testCreateFloatFailure("\b\t\n\f\r");
- // Funky whitespaces
- testCreateFloatFailure("\u00A0\uFEFF\u000B\u000C\u001C\u001D\u001E\u001F");
}
+ @ParameterizedTest
+ @ValueSource(strings = {
+ // @formatter:off
+ "",
+ " ",
+ "\b\t\n\f\r",
+ // Funky whitespaces
+ "\u00A0\uFEFF\u000B\u000C\u001C\u001D\u001E\u001F" })
+ // @formatter:on
protected void testCreateFloatFailure(final String str) {
assertThrows(NumberFormatException.class, () -> NumberUtils.createFloat(str), "createFloat(\"" + str + "\") should have failed.");
}