Best Easymock code snippet using org.easymock.internal.PrimitiveUtils.PrimitiveUtils
Source:PrimitiveUtilsTest.java
...18import static org.junit.Assert.*;19/**20 * @author Henri Tremblay21 */22public class PrimitiveUtilsTest {23 @Test24 public void getEmptyValue() {25 assertNull(PrimitiveUtils.getEmptyValue(Void.TYPE));26 assertEquals(false, PrimitiveUtils.getEmptyValue(Boolean.TYPE));27 assertEquals((byte) 0, PrimitiveUtils.getEmptyValue(Byte.TYPE));28 assertEquals((short) 0, PrimitiveUtils.getEmptyValue(Short.TYPE));29 assertEquals((char) 0, PrimitiveUtils.getEmptyValue(Character.TYPE));30 assertEquals(0, PrimitiveUtils.getEmptyValue(Integer.TYPE));31 assertEquals(0L, PrimitiveUtils.getEmptyValue(Long.TYPE));32 assertEquals((float) 0, PrimitiveUtils.getEmptyValue(Float.TYPE));33 assertEquals((double) 0, PrimitiveUtils.getEmptyValue(Double.TYPE));34 }35 @Test36 public void getWrapperType() {37 assertEquals(Void.class, PrimitiveUtils.getWrapperType(Void.TYPE));38 assertEquals(Boolean.class, PrimitiveUtils.getWrapperType(Boolean.TYPE));39 assertEquals(Byte.class, PrimitiveUtils.getWrapperType(Byte.TYPE));40 assertEquals(Short.class, PrimitiveUtils.getWrapperType(Short.TYPE));41 assertEquals(Character.class, PrimitiveUtils.getWrapperType(Character.TYPE));42 assertEquals(Integer.class, PrimitiveUtils.getWrapperType(Integer.TYPE));43 assertEquals(Long.class, PrimitiveUtils.getWrapperType(Long.TYPE));44 assertEquals(Float.class, PrimitiveUtils.getWrapperType(Float.TYPE));45 assertEquals(Double.class, PrimitiveUtils.getWrapperType(Double.TYPE));46 }47 @Test48 public void isNumberWrapper() {49 assertTrue(PrimitiveUtils.isPrimitiveWrapper(Byte.class));50 assertTrue(PrimitiveUtils.isPrimitiveWrapper(Short.class));51 assertTrue(PrimitiveUtils.isPrimitiveWrapper(Integer.class));52 assertTrue(PrimitiveUtils.isPrimitiveWrapper(Long.class));53 assertTrue(PrimitiveUtils.isPrimitiveWrapper(Float.class));54 assertTrue(PrimitiveUtils.isPrimitiveWrapper(Double.class));55 assertFalse(PrimitiveUtils.isPrimitiveWrapper(getClass()));56 assertFalse(PrimitiveUtils.isPrimitiveWrapper(Integer.TYPE));57 }58 @Test59 public void getPrimitiveTypeNameFromWrapper() {60 assertPrimitiveName(Byte.TYPE, Byte.class);61 assertPrimitiveName(Short.TYPE, Short.class);62 assertPrimitiveName(Integer.TYPE, Integer.class);63 assertPrimitiveName(Long.TYPE, Long.class);64 assertPrimitiveName(Float.TYPE, Float.class);65 assertPrimitiveName(Double.TYPE, Double.class);66 assertNull(PrimitiveUtils.getPrimitiveTypeNameFromWrapper(getClass()));67 assertNull(PrimitiveUtils.getPrimitiveTypeNameFromWrapper(Long.TYPE));68 }69 private void assertPrimitiveName(Class<?> expected, Class<?> actual) {70 assertEquals(expected.getName(), PrimitiveUtils.getPrimitiveTypeNameFromWrapper(actual));71 }72}...
PrimitiveUtils
Using AI Code Generation
1public static Class<?> toWrapperClass(Class<?> primitive) {2 if (primitive == boolean.class) {3 return Boolean.class;4 } else if (primitive == byte.class) {5 return Byte.class;6 } else if (primitive == char.class) {7 return Character.class;8 } else if (primitive == double.class) {9 return Double.class;10 } else if (primitive == float.class) {11 return Float.class;12 } else if (primitive == int.class) {13 return Integer.class;14 } else if (primitive == long.class) {15 return Long.class;16 } else if (primitive == short.class) {17 return Short.class;18 } else if (primitive == void.class) {19 return Void.class;20 }21 return primitive;22}23public static Class<?> toPrimitiveClass(Class<?> wrapper) {24 if (wrapper == Boolean.class) {25 return boolean.class;26 } else if (wrapper == Byte.class) {27 return byte.class;28 } else if (wrapper == Character.class) {29 return char.class;30 } else if (wrapper == Double.class) {31 return double.class;32 } else if (wrapper == Float.class) {33 return float.class;34 } else if (wrapper == Integer.class) {35 return int.class;36 } else if (wrapper == Long.class) {37 return long.class;38 } else if (wrapper == Short.class) {39 return short.class;40 } else if (wrapper == Void.class) {41 return void.class;42 }43 return wrapper;44}45public static Class<?> toWrapperClass(Class<?> primitive) {46 if (primitive == boolean.class) {47 return Boolean.class;48 } else if (primitive == byte.class) {49 return Byte.class;50 } else if (
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!