mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
修复VersionComparator传入空字符串报错问题
This commit is contained in:
@@ -3,9 +3,6 @@ package cn.hutool.core.comparator;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 版本比较单元测试
|
||||
*
|
||||
@@ -13,6 +10,17 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class VersionComparatorTest {
|
||||
|
||||
@Test
|
||||
public void compareEmptyTest() {
|
||||
int compare = VersionComparator.INSTANCE.compare("", "1.12.1");
|
||||
Assert.assertTrue(compare < 0);
|
||||
|
||||
compare = VersionComparator.INSTANCE.compare("", null);
|
||||
Assert.assertTrue(compare > 0);
|
||||
compare = VersionComparator.INSTANCE.compare(null, "");
|
||||
Assert.assertTrue(compare < 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void versionComparatorTest1() {
|
||||
int compare = VersionComparator.INSTANCE.compare("1.2.1", "1.12.1");
|
||||
|
Reference in New Issue
Block a user