package net.sf.javaml.core; import static org.junit.Assert.*; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Random; import org.junit.Test; public class TestFold { @Test public void test(){ List instances = new ArrayList(); for(int i = 0; i < 100; i++) instances.add(new DenseInstance(new double[]{1, 2, i})); DefaultDataset dd = new DefaultDataset(instances); Fold f = new Fold(dd, new int[]{0, 1, 2}); assertNotNull(f.classes()); try{ f.add(new DenseInstance(new double[]{0.0, 1.2})); }catch(UnsupportedOperationException uoe){} try{ f.folds(0, new Random()); }catch(UnsupportedOperationException uoe){} assertNotNull(f.instance(0)); try{ f.kNearest(1, new DenseInstance(new double[]{0.0, 1.2}), null); }catch(UnsupportedOperationException uoe){} try{ f.add(0, new DenseInstance(new double[]{0.0, 1.2})); }catch(UnsupportedOperationException uoe){} try{ f.addAll(instances); }catch(UnsupportedOperationException uoe){} try{ f.addAll(0, instances); }catch(UnsupportedOperationException uoe){} try{ f.clear(); }catch(UnsupportedOperationException uoe){} try{ f.contains(instances); }catch(UnsupportedOperationException uoe){} try{ f.containsAll(instances); }catch(UnsupportedOperationException uoe){} assertNotNull(f.get(0)); try{ f.indexOf(instances); }catch(UnsupportedOperationException uoe){} assertFalse(f.isEmpty()); Iterator fi = f.iterator(); while(fi.hasNext()) fi.next(); try{ f.lastIndexOf(instances); }catch(UnsupportedOperationException uoe){} fi = f.listIterator(); while(fi.hasNext()){ fi.next(); try{ fi.remove(); }catch(UnsupportedOperationException uoe){} } fi = f.listIterator(0); try{ f.remove(instances); }catch(UnsupportedOperationException uoe){} try{ f.removeAll(instances); }catch(UnsupportedOperationException uoe){} try{ f.retainAll(instances); }catch(UnsupportedOperationException uoe){} try{ f.set(0, instances.get(0)); }catch(UnsupportedOperationException uoe){} assertEquals(3, f.size()); try{ f.subList(0, 5); }catch(UnsupportedOperationException uoe){} assertNotNull(f.toArray()); assertNotNull(f.toArray(new Instance[]{})); assertEquals(3, f.noAttributes()); f.classIndex(null); f.classValue(0); assertNotNull(f.copy()); } }