MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / testSplitList

Method testSplitList

JSAT/test/jsat/utils/ListUtilsTest.java:43–75  ·  view source on GitHub ↗

Test of splitList method, of class ListUtils.

()

Source from the content-addressed store, hash-verified

41 * Test of splitList method, of class ListUtils.
42 */
43 @Test
44 public void testSplitList()
45 {
46 System.out.println("splitList");
47 List<Integer> sourceList = new IntList(500);
48 for(int i = 0; i < 500; i++)
49 sourceList.add(i);
50 List<List<Integer>> ll1 = ListUtils.splitList(sourceList, 5);
51 assertEquals(5, ll1.size());
52
53 for(int i = 0; i < 5; i++)
54 {
55 List<Integer> l = ll1.get(i);
56 assertEquals(100, l.size());
57 for(int j = 0; j < l.size(); j++)
58 assertEquals( i*100+j, l.get(j).intValue());//intValue called b/c it becomes ambigous to the compiler without it
59 }
60
61
62 ll1 = ListUtils.splitList(sourceList, 7);//Non divisible amount
63 assertEquals(7, ll1.size());
64 int pos = 0;
65 for(List<Integer> l : ll1)
66 {
67 assertTrue("List should have had only 71 or 72 values", l.size() == 72 || l.size() == 71 );
68 for(int j = 0; j < l.size(); j++)
69 {
70 assertEquals(pos+j, l.get(j).intValue());
71 }
72 pos += l.size();
73 }
74 assertEquals(500, pos);
75 }
76
77 @Test
78 public void testSwap()

Callers

nothing calls this directly

Calls 4

addMethod · 0.95
splitListMethod · 0.95
sizeMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected