Menu

[572a65]: / src / junit / utils / TestArrayUtils.java  Maximize  Restore  History

Download this file

43 lines (34 with data), 1.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* %SVN.HEADER%
*/
package junit.utils;
import java.util.Arrays;
import junit.framework.Assert;
import net.sf.javaml.utils.ArrayUtils;
import org.junit.Test;
public class TestArrayUtils {
@Test
public void testArrayUtils(){
double[]arr={1,5,4,3,8,10,2,6};
int[]order=ArrayUtils.sort(arr);
System.out.println(Arrays.toString(order));
}
@Test
public void testReverse(){
double[]arr={1,2,3,4,5};
ArrayUtils.reverse(arr);
System.out.println(Arrays.toString(arr));
Assert.assertEquals(5.0, arr[0]);
Assert.assertEquals(4.0, arr[1]);
Assert.assertEquals(3.0, arr[2]);
Assert.assertEquals(2.0, arr[3]);
Assert.assertEquals(1.0, arr[4]);
int[]arr2=new int[]{1,2,3,4};
ArrayUtils.reverse(arr2);
System.out.println(Arrays.toString(arr2));
Assert.assertEquals(4, arr2[0]);
Assert.assertEquals(3, arr2[1]);
Assert.assertEquals(2, arr2[2]);
Assert.assertEquals(1, arr2[3]);
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.