Home | History | Annotate | Download | only in internal
      1 package junitparams.internal;
      2 
      3 import static org.assertj.core.api.Assertions.assertThat;
      4 
      5 import org.junit.Test;
      6 
      7 public class UtilsTest {
      8 
      9     @Test
     10     public void shouldSafelyCastStringArrayParamSetToArray() {
     11         // given
     12         Object paramSet = new String[] {"this", "is", "a", "test"};
     13 
     14         // when
     15         Object[] result = Utils.safelyCastParamsToArray(paramSet);
     16 
     17         // then
     18         assertThat(result).containsExactly("this", "is", "a", "test");
     19     }
     20 
     21     @Test
     22     public void shouldSafelyCastIntegerArrayParamSetToArray() {
     23         // given
     24         Object paramSet = new Integer[] {1, 2, 3, 4};
     25 
     26         // when
     27         Object[] result = Utils.safelyCastParamsToArray(paramSet);
     28 
     29         // then
     30         assertThat(result).containsExactly(1, 2, 3, 4);
     31     }
     32 
     33     @Test
     34     public void shouldSafelyCastArrayParamSetToArray() {
     35         // given
     36         Object paramSet = new Object[] {1, "2", 30D};
     37 
     38         // when
     39         Object[] result = Utils.safelyCastParamsToArray(paramSet);
     40 
     41         // then
     42         assertThat(result).containsExactly(1, "2", 30D);
     43     }
     44 
     45     @Test
     46     public void shouldCreateSingletonArrayWhenCastingObjectToArray() {
     47         // given
     48         Object paramSet = "test";
     49 
     50         // when
     51         Object[] result = Utils.safelyCastParamsToArray(paramSet);
     52 
     53         // then
     54         assertThat(result).containsExactly("test");
     55     }
     56 }
     57