<commit_before>package net.emaze.dysfunctional.ranges;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import net.emaze.dysfunctional.consumers.Consumers;
import net.emaze.dysfunctional.order.ComparableComparator;
import net.emaze.dysfunctional.order.IntegerSequencingPolicy;
import net.emaze.dysfunctional.tuples.Pair;
import org.junit.Assert;
import org.junit.Test;

/**
 *
 * @author rferranti
 */
public class CountsTest {

    @Test
    public void canGetCountedIterator() {
        List<String> bucket = Arrays.asList("a","b");
        Iterable<Pair<Integer,String>> iterable = Counts.counted(bucket);
        Assert.assertEquals(Arrays.asList(Pair.of(0,"a"), Pair.of(1,"b")), Consumers.all(iterable));
    }

    @Test
    public void canGetCountedIteratorWithRange() {
        Range<Integer> range = new DenseRange<Integer>(new IntegerSequencingPolicy(), new ComparableComparator<Integer>(), 1, 10);
        List<String> bucket = Arrays.asList("a","b");
        Iterable<Pair<Integer,String>> iterable = Counts.counted(bucket, range);
        Assert.assertEquals(Arrays.asList(Pair.of(1,"a"), Pair.of(2,"b")), Consumers.all(iterable));
    }

    @Test(expected=IllegalArgumentException.class)
    public void cannotCallCountedWithANullIterable() {
        final Iterable<Object> iterable = null;
        Counts.counted(iterable);
    }

    @Test(expected=IllegalArgumentException.class)
    public void cannotCallCountedWithANullIterableAndARange() {
        final Iterable<Object> iterable = null;
        final StubRange range = new StubRange();
        Counts.counted(iterable, range);
    }

    private static class StubRange implements Range<Object> {

        @Override
        public boolean contains(Object element) {
            return false;
        }

        @Override
        public boolean overlaps(Range<Object> rhs) {
            return false;
        }

        @Override
        public Object lower() {
            return null;
        }

        @Override
        public Object upper() {
            return null;
        }

        @Override
        public List<DenseRange<Object>> densified() {
            return null;
        }

        @Override
        public Iterator<Object> iterator() {
            return null;
        }

        @Override
        public int compareTo(Range<Object> o) {
           return 0;
        }

    }

}<commit_msg>ref: reformat<commit_after>package net.emaze.dysfunctional.ranges;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import net.emaze.dysfunctional.consumers.Consumers;
import net.emaze.dysfunctional.order.ComparableComparator;
import net.emaze.dysfunctional.order.IntegerSequencingPolicy;
import net.emaze.dysfunctional.tuples.Pair;
import org.junit.Assert;
import org.junit.Test;

/**
 *
 * @author rferranti
 */
public class CountsTest {

    @Test
    public void canGetCountedIterator() {
        List<String> bucket = Arrays.asList("a", "b");
        Iterable<Pair<Integer, String>> iterable = Counts.counted(bucket);
        Assert.assertEquals(Arrays.asList(Pair.of(0, "a"), Pair.of(1, "b")), Consumers.all(iterable));
    }

    @Test
    public void canGetCountedIteratorWithRange() {
        Range<Integer> range = new DenseRange<Integer>(new IntegerSequencingPolicy(), new ComparableComparator<Integer>(), 1, 10);
        List<String> bucket = Arrays.asList("a", "b");
        Iterable<Pair<Integer, String>> iterable = Counts.counted(bucket, range);
        Assert.assertEquals(Arrays.asList(Pair.of(1, "a"), Pair.of(2, "b")), Consumers.all(iterable));
    }

    @Test(expected = IllegalArgumentException.class)
    public void cannotCallCountedWithANullIterable() {
        final Iterable<Object> iterable = null;
        Counts.counted(iterable);
    }

    @Test(expected = IllegalArgumentException.class)
    public void cannotCallCountedWithANullIterableAndARange() {
        final Iterable<Object> iterable = null;
        final StubRange range = new StubRange();
        Counts.counted(iterable, range);
    }

    private static class StubRange implements Range<Object> {

        @Override
        public boolean contains(Object element) {
            return false;
        }

        @Override
        public boolean overlaps(Range<Object> rhs) {
            return false;
        }

        @Override
        public Object lower() {
            return null;
        }

        @Override
        public Object upper() {
            return null;
        }

        @Override
        public List<DenseRange<Object>> densified() {
            return null;
        }

        @Override
        public Iterator<Object> iterator() {
            return null;
        }

        @Override
        public int compareTo(Range<Object> o) {
            return 0;
        }
    }
}
{'fraction_non_alphanumeric': 0.11088082901554404, 'fraction_numerical': 0.003316062176165803, 'mean_word_length': 2.7094542659492697, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '935585', 'n_tokens_mistral': 1434, 'n_tokens_neox': 1379, 'n_words': 283}