This commit is contained in:
looly 2022-01-05 18:45:45 +08:00
parent 24569b81c8
commit f8017c31d5
4 changed files with 17 additions and 7 deletions

View File

@ -21,6 +21,7 @@
* 【core 】 修复CsvParser行号有误问题pr#2065@Github
* 【http 】 修复HttpRequest.of无法自动添加http前缀问题issue#I4PEYL@Gitee
* 【core 】 修复 `CharSequenceUtil.brief(str, maxLength)` 方法字符串越界问题,以及 `maxLength` 部分值时结果与预期不符的问题pr#2068@Github
* 【core 】 修复NamingCase中转换下划线字母+数字转换问题issue#2070@Github
-------------------------------------------------------------------------------------------------------------
# 5.7.18 (2021-12-25)

View File

@ -90,7 +90,7 @@ public class NamingCase {
} else if (Character.isLowerCase(preChar)) {
// 前一个为小写
sb.append(symbol);
if (null == nextChar || Character.isLowerCase(nextChar)) {
if (null == nextChar || Character.isLowerCase(nextChar) || CharUtil.isNumber(nextChar)) {
//普通首字母大写如aBcc -> a_bcc
c = Character.toLowerCase(c);
}

View File

@ -0,0 +1,15 @@
package cn.hutool.core.text;
import cn.hutool.core.lang.Dict;
import org.junit.Assert;
import org.junit.Test;
public class NamingCaseTest {
@Test
public void toUnderlineCaseTest(){
// https://github.com/dromara/hutool/issues/2070
Dict.create()
.set("customerNickV2", "customer_nick_v2")
.forEach((key, value) -> Assert.assertEquals(value, NamingCase.toUnderlineCase(key)));
}
}

View File

@ -421,12 +421,6 @@ public class StrUtilTest {
.set("HelloWorld_test", "hello_world_test")
.set("H2", "H2")
.set("H#case", "H#case")
.forEach((key, value) -> Assert.assertEquals(value, StrUtil.toUnderlineCase(key)));
}
@Test
public void toUnderLineCaseTest2() {
Dict.create()
.set("PNLabel", "PN_label")
.forEach((key, value) -> Assert.assertEquals(value, StrUtil.toUnderlineCase(key)));
}