<commit_before>// Copyright 2013 <NAME>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package eu.danieldk.fsadict;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import eu.danieldk.fsadict.categories.Tests;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;

@Category(Tests.class)
public class DictionaryTest {
	private List<String> d_words1;
	private List<String> d_words2;
	private Dictionary d_dict;

	@SuppressWarnings("serial")
	@Before
	public void initialize() throws DictionaryBuilderException
	{
		d_words1 = new ArrayList<String>(){{
			add("al");
			add("alleen");
			add("avonden");
			add("zeemeeuw");
			add("zeker");
			add("zeven");
			add("zoeven");
		}};

		d_words2 = new ArrayList<String>(){{
			add("als");
			add("allen");
			add("avond");
			add("zeemeeuwen");
			add("zeer");
			add("zepen");
			add("zoef");
		}};

		d_dict = new DictionaryBuilder().addAll(d_words1).build();
	}

    @Test(expected = UnsupportedOperationException.class)
    public void addTest()
    {
        d_dict.add("foo");
    }

    @Test(expected = UnsupportedOperationException.class)
    public void addAllTest()
    {
        d_dict.addAll(d_words2);
    }

    @Test(expected = UnsupportedOperationException.class)
    public void clearTest()
    {
        d_dict.clear();
    }

	@Test
	public void containsTest()
	{
		for (String word: d_words1)
			Assert.assertTrue(d_dict.contains(word));
	}

    @Test
    public void containsAllTest()
    {
        Assert.assertTrue(d_dict.containsAll(d_words1));
        Assert.assertFalse(d_dict.containsAll(d_words2));
    }

	@Test
	public void doesNotContainWordsTest()
	{
		for (String word: d_words2)
			Assert.assertTrue(!d_dict.contains(word));
	}

    @Test
    public void emptyTest()
    {
        Dictionary dict = new DictionaryBuilder().build();
        Assert.assertFalse(dict.contains("foo"));
        Assert.assertEquals(0, dict.size());
    }

    @Test
    public void isEmptyTest()
    {
        Assert.assertFalse(d_dict.isEmpty());
        Dictionary dict = new DictionaryBuilder().build();
        Assert.assertTrue(dict.isEmpty());
    }

	@Test
	public void iterationTest()
	{
		List<CharSequence> listFromIteration = new LinkedList<CharSequence>();
		for (CharSequence seq: d_dict)
			listFromIteration.add(seq);
		Assert.assertEquals(d_words1, listFromIteration);
	}

    @Test(expected = UnsupportedOperationException.class)
    public void removeTest()
    {
        d_dict.remove("foo");
    }
<commit_msg>Dictionary iterator remove() method test.<commit_after>// Copyright 2013 <NAME>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package eu.danieldk.fsadict;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import eu.danieldk.fsadict.categories.Tests;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;

@Category(Tests.class)
public class DictionaryTest {
	private List<String> d_words1;
	private List<String> d_words2;
	private Dictionary d_dict;

	@SuppressWarnings("serial")
	@Before
	public void initialize() throws DictionaryBuilderException
	{
		d_words1 = new ArrayList<String>(){{
			add("al");
			add("alleen");
			add("avonden");
			add("zeemeeuw");
			add("zeker");
			add("zeven");
			add("zoeven");
		}};

		d_words2 = new ArrayList<String>(){{
			add("als");
			add("allen");
			add("avond");
			add("zeemeeuwen");
			add("zeer");
			add("zepen");
			add("zoef");
		}};

		d_dict = new DictionaryBuilder().addAll(d_words1).build();
	}

    @Test(expected = UnsupportedOperationException.class)
    public void addTest()
    {
        d_dict.add("foo");
    }

    @Test(expected = UnsupportedOperationException.class)
    public void addAllTest()
    {
        d_dict.addAll(d_words2);
    }

    @Test(expected = UnsupportedOperationException.class)
    public void clearTest()
    {
        d_dict.clear();
    }

	@Test
	public void containsTest()
	{
		for (String word: d_words1)
			Assert.assertTrue(d_dict.contains(word));
	}

    @Test
    public void containsAllTest()
    {
        Assert.assertTrue(d_dict.containsAll(d_words1));
        Assert.assertFalse(d_dict.containsAll(d_words2));
    }

	@Test
	public void doesNotContainWordsTest()
	{
		for (String word: d_words2)
			Assert.assertTrue(!d_dict.contains(word));
	}

    @Test
    public void emptyTest()
    {
        Dictionary dict = new DictionaryBuilder().build();
        Assert.assertFalse(dict.contains("foo"));
        Assert.assertEquals(0, dict.size());
    }

    @Test
    public void isEmptyTest()
    {
        Assert.assertFalse(d_dict.isEmpty());
        Dictionary dict = new DictionaryBuilder().build();
        Assert.assertTrue(dict.isEmpty());
    }

	@Test
	public void iterationTest()
	{
		List<CharSequence> listFromIteration = new LinkedList<CharSequence>();
		for (CharSequence seq: d_dict)
			listFromIteration.add(seq);
		Assert.assertEquals(d_words1, listFromIteration);
	}

    @Test(expected = UnsupportedOperationException.class)
    public void iteratorRemoveTest()
    {
        Iterator<String> iter = d_dict.iterator();
        if (iter.hasNext())
            iter.remove();
    }

    @Test(expected = UnsupportedOperationException.class)
    public void removeTest()
    {
        d_dict.remove("foo");
    }

{'fraction_non_alphanumeric': 0.12644742936544698, 'fraction_numerical': 0.006175698625907056, 'mean_word_length': 3.4861495844875345, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3829692', 'n_tokens_mistral': 2089, 'n_tokens_neox': 1978, 'n_words': 471}