Browse Source

update: 新增equals方法及单测

remotes/1611766341912730171/master
zjz1993 5 years ago
parent
commit
efbe7a0460
  1. 13
      src/main/java/com/fanruan/api/util/GeneralKit.java
  2. 24
      src/test/java/com/fanruan/api/util/GeneralKitTest.java

13
src/main/java/com/fanruan/api/util/GeneralKit.java

@ -4,6 +4,7 @@ import com.fr.base.FRContext;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils;
import com.fr.stable.CommonUtils;
import com.fr.stable.StringUtils;
import com.fr.third.guava.base.Objects;
import com.fr.stable.StableUtils;
import org.jetbrains.annotations.NotNull;
@ -83,7 +84,7 @@ public class GeneralKit {
public static String join(Object[] array, String se) {
return StableUtils.join(array, se);
}
/*
/**
* 返回国际化区属
* @return 国际化后区域属性
*/
@ -91,4 +92,14 @@ public class GeneralKit {
public static Locale getLocale() {
return FRContext.getLocale();
}
/**
* 检测两个数组是否相等
* @param array1 数组1
* @param array2 数组2
* @return 判断的结果
* */
public static <T> boolean equals(T[] array1, T[] array2){
return ComparatorUtils.equals(array1, array2);
}
}

24
src/test/java/com/fanruan/api/util/GeneralKitTest.java

@ -52,4 +52,28 @@ public class GeneralKitTest extends Prepare {
public void getLocale() {
Assert.assertEquals(GeneralKit.getLocale(), Locale.CHINA);
}
@Test
public void equals(){
Object objArray[] = {1,2,3};
Integer intArray[] = {1,2,3};
Long[] longArray = {1L,2L,3L};
Double doubleArray[] = {1.1,2.2,3.3};
Byte[] byteArray = {1,2,3};
Character[] charArray = {'a', 'b', 'c'};
Boolean booleanArray[] = {true,true,false};
Assert.assertEquals(GeneralKit.equals(objArray, new Object[]{1,2,3}), true);
Assert.assertEquals(GeneralKit.equals(objArray, new Object[]{1,2,3,4}), false);
Assert.assertEquals(GeneralKit.equals(intArray, new Integer[]{1,2,3}), true);
Assert.assertEquals(GeneralKit.equals(intArray, new Integer[]{1,2,3,4}), false);
Assert.assertEquals(GeneralKit.equals(longArray, new Long[]{1L,2L,3L}), true);
Assert.assertEquals(GeneralKit.equals(longArray, new Long[]{1L,2L,3L,4L}), false);
Assert.assertEquals(GeneralKit.equals(doubleArray, new Double[]{1.1,2.2,3.3}), true);
Assert.assertEquals(GeneralKit.equals(doubleArray, new Double[]{1.1,2.2,3.3,4.4}), false);
Assert.assertEquals(GeneralKit.equals(byteArray, new Byte[]{1,2,3}), true);
Assert.assertEquals(GeneralKit.equals(byteArray, new Byte[]{1,2,3,4}), false);
Assert.assertEquals(GeneralKit.equals(charArray, new Character[]{'a','b','c'}), true);
Assert.assertEquals(GeneralKit.equals(charArray, new Character[]{'a','b','c','d'}), false);
Assert.assertEquals(GeneralKit.equals(booleanArray, new Boolean[]{true,true,false}), true);
Assert.assertEquals(GeneralKit.equals(booleanArray, new Boolean[]{true,true,false,false}), false);
}
}
Loading…
Cancel
Save