/*
 * @author Ranides Atterwim <ranides@gmail.com>
 * @copyright Ranides Atterwim
 * @license WTFPL
 * @url http://ranides.net/projects/assira
 */
package net.ranides.assira.collection.lists;

import net.ranides.assira.ContractTesters;
import net.ranides.assira.collection.mockup.TMaps;
import net.ranides.assira.test.TCollection;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author Ranides Atterwim <ranides@gmail.com>
 */
public class IntVirtualListTest {

	@Test
	public void testContract() {
		TCollection<Integer> $var = TMaps.MAP_IS.keys();

		ContractTesters.runner()
			.param("collection!", $var)
			.function(new int[0], array -> new MutableVList($var.list(array).valuesInt()))
			.run();
		assertTrue(true);
	}
	
	private static final class MutableVList extends IntVirtualList {
		
		private final IntList list;

		public MutableVList(int[] array) {
			this.list = new IntArrayList(array);
		}
		
		@Override
		public int size() {
			return list.size();
		}

		@Override
		public int getInt(int index) {
			return list.getInt(index);
		}
		
		@Override
		public void add(int index, int element) {
			list.add(index, element);
		}

		@Override
		public int set(int index, int element) {
			return list.set(index, element);
		}

		@Override
		public int removeInt(int index) {
			return list.removeInt(index);
		}
		
		
	}
	
}
