add methods

This commit is contained in:
Looly
2022-05-05 11:52:51 +08:00
parent fa9d095e4e
commit 78a5c53d98
10 changed files with 111 additions and 26 deletions

View File

@@ -1,5 +1,6 @@
package cn.hutool.core.lang;
import cn.hutool.core.text.StrUtil;
import org.junit.Test;
public class AssertTest {
@@ -35,4 +36,27 @@ public class AssertTest {
//noinspection ConstantConditions
Assert.isTrue(i > 0, ()-> new IndexOutOfBoundsException("relation message to return"));
}
@Test
public void equalsTest() {
//String a="ab";
//final String b = new String("abc");
final String a = null;
final String b = null;
Assert.equals(a, b);
Assert.equals(a, b, "{}不等于{}", a, b);
Assert.equals(a, b, () -> new RuntimeException(StrUtil.format("{}和{}不相等", a, b)));
}
@Test
public void notEqualsTest() {
//String c="19";
//final String d = new String("19");
final String c = null;
final String d = "null";
//Assert.notEquals(c,d);
//Assert.notEquals(c,d,"{}等于{}",c,d);
Assert.notEquals(c, d, () -> new RuntimeException(StrUtil.format("{}和{}相等", c, d)));
}
}