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

import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;
import java.util.regex.Pattern;
import net.ranides.assira.collection.iterators.IntIterator;
import net.ranides.assira.ContractTesters;
import net.ranides.assira.collection.mockup.TMaps;
import net.ranides.assira.test.TCollection;
import org.junit.Test;

/**
 *
 * @author Ranides Atterwim <ranides@gmail.com>
 */
public class AIntSetTest {
    
    private final TCollection<Integer> $var = TMaps.MAP_IS.keys();
    
    @Test
    public void testSuite() {
        ContractTesters.runner()
            .param("collection!", $var)
			.ignore(Pattern.compile(".*_HC"))
            .function(new int[0], array -> $var.list(array).into(new ATSet($var.comparator())))
			.run();
    }
    
    private static class ATSet extends AIntSet {
        
        private final Set<Integer> data;

        public ATSet(Comparator<Integer> cmp) {
            data = new TreeSet<>(cmp);
        }

        @Override
        public boolean add(int key) {
            return data.add(key);
        }

        @Override
        public boolean contains(int key) {
            return data.contains(key);
        }
        
        @Override
        public void clear() {
            data.clear();
        }
        
        @Override
        public int size() {
            return data.size();
        }
        
        @Override
        public boolean remove(int key) {
            return data.remove(key);
        }

        @Override
        public IntIterator iterator() {
            return IntIterator.wrap(data.iterator());
        }

        

    }
    
}
