import "copyrightAndOthers.stg"
import "primitiveHashCode.stg"
import "primitiveLiteral.stg"

isTest() ::= "true"

targetPath() ::= "org/eclipse/collections/impl/set/mutable/primitive"

fileName(primitive) ::= "Unmodifiable<primitive.name>SetTest"

class(primitive) ::= <<
<body(primitive.type, primitive.wrapperName, primitive.name)>
>>

body(type, wrapperName, name) ::= <<
<copyrightAndOthers()>

package org.eclipse.collections.impl.set.mutable.primitive;

import java.util.NoSuchElementException;

import org.eclipse.collections.api.iterator.<name>Iterator;
import org.eclipse.collections.api.iterator.Mutable<name>Iterator;
import org.eclipse.collections.impl.block.factory.primitive.<name>Predicates;
import org.junit.Assert;
import org.junit.Test;

/**
 * JUnit test for {@link Unmodifiable<name>Set}.
 * This file was automatically generated from template file unmodifiablePrimitiveSetTest.stg.
 */
public class Unmodifiable<name>SetTest extends Abstract<name>SetTestCase
{
    @Override
    protected final Unmodifiable<name>Set classUnderTest()
    {
        return new Unmodifiable<name>Set(<name>HashSet.newSetWith(<["1", "2", "3"]:(literal.(type))(); separator=", ">));
    }

    @Override
    protected Unmodifiable<name>Set newWith(<type>... elements)
    {
        return new Unmodifiable<name>Set(<name>HashSet.newSetWith(elements));
    }

    @Override
    @Test(expected = UnsupportedOperationException.class)
    public void clear()
    {
        this.classUnderTest().clear();
    }

    @Override
    @Test(expected = UnsupportedOperationException.class)
    public void add()
    {
        this.newWith().add(<(literal.(type))("1")>);
    }

    <if(primitive.floatingPoint)><NaNTests()><endif>
    @Override
    @Test(expected = UnsupportedOperationException.class)
    public void addAllArray()
    {
        this.classUnderTest().addAll();
    }

    @Override
    @Test(expected = UnsupportedOperationException.class)
    public void addAllIterable()
    {
        this.classUnderTest().addAll(this.newMutableCollectionWith());
    }

    @Override
    @Test(expected = UnsupportedOperationException.class)
    public void remove()
    {
        this.classUnderTest().remove(<(literal.(type))("1")>);
    }

    @Override
    @Test(expected = UnsupportedOperationException.class)
    public void removeIf()
    {
        this.classUnderTest().removeIf(<name>Predicates.equal(<(literal.(type))("1")>));
    }

    @Override
    @Test(expected = UnsupportedOperationException.class)
    public void removeAll()
    {
        this.classUnderTest().removeAll();
    }

    @Override
    @Test(expected = UnsupportedOperationException.class)
    public void removeAll_iterable()
    {
        this.classUnderTest().removeAll(this.newMutableCollectionWith());
    }

    @Override
    @Test(expected = UnsupportedOperationException.class)
    public void retainAll()
    {
        this.classUnderTest().retainAll();
    }

    @Override
    @Test(expected = UnsupportedOperationException.class)
    public void retainAll_iterable()
    {
        this.classUnderTest().retainAll(this.newMutableCollectionWith());
    }

    @Override
    @Test(expected = UnsupportedOperationException.class)
    public void with()
    {
        this.newWith().with(<["1"]:(literal.(type))(); separator=", ">);
    }

    @Override
    @Test(expected = UnsupportedOperationException.class)
    public void withAll()
    {
        this.newWith().withAll(this.newMutableCollectionWith(<(literal.(type))("1")>));
    }

    @Override
    @Test(expected = UnsupportedOperationException.class)
    public void without()
    {
        this.newWith(<["1", "2", "3", "4", "5"]:(literal.(type))(); separator=", ">).without(<(literal.(type))("9")>);
    }

    @Override
    @Test(expected = UnsupportedOperationException.class)
    public void withoutAll()
    {
        this.newWith(<["1", "2", "3", "4", "5"]:(literal.(type))(); separator=", ">).withoutAll(this.newMutableCollectionWith(<["8", "9"]:(literal.(type))(); separator=", ">));
    }

    @Override
    @Test
    public void contains()
    {
        Unmodifiable<name>Set set = this.newWith(<["14", "2", "30", "31", "32", "35", "0", "1"]:(literal.(type))(); separator=", ">);
        Assert.assertFalse(set.contains(<(literal.(type))("29")>));
        Assert.assertFalse(set.contains(<(literal.(type))("49")>));

        <type>[] numbers = {<["14", "2", "30", "31", "32", "35", "0", "1"]:(literal.(type))(); separator=", ">};
        for (<type> number : numbers)
        {
            Assert.assertTrue(set.contains(number));
        }

        Assert.assertFalse(set.contains(<(literal.(type))("-1")>));
        Assert.assertFalse(set.contains(<(literal.(type))("29")>));
        Assert.assertFalse(set.contains(<(literal.(type))("49")>));

        Unmodifiable<name>Set set1 = this.newWith(<["0", "1", "1", "2", "2", "2"]:(literal.(type))(); separator=", ">);
        Assert.assertTrue(set1.contains(<(literal.(type))("0")>));
        Assert.assertTrue(set1.contains(<(literal.(type))("1")>));
        Assert.assertTrue(set1.contains(<(literal.(type))("2")>));
        Assert.assertFalse(set1.contains(<(literal.(type))("3")>));
    }

    @Override
    @Test(expected = NoSuchElementException.class)
    public void <type>Iterator_throws_non_empty_collection()
    {
        Unmodifiable<name>Set set = this.newWith(<["1", "2", "3"]:(literal.(type))(); separator=", ">);
        <name>Iterator iterator = set.<type>Iterator();
        while (iterator.hasNext())
        {
            iterator.next();
        }
        iterator.next();
    }

    @Override
    @Test
    public void asUnmodifiable()
    {
        Unmodifiable<name>Set set = this.classUnderTest();
        super.asUnmodifiable();
        Assert.assertSame(set, set.asUnmodifiable());
        Assert.assertEquals(set, set.asUnmodifiable());
    }

    @Override
    public void <type>Iterator_with_remove()
    {
        Mutable<name>Iterator iterator = this.classUnderTest().<type>Iterator();
        Assert.assertTrue(iterator.hasNext());
        iterator.next();
        Assert.assertThrows(UnsupportedOperationException.class, iterator::remove);
    }

    @Override
    public void <type>Iterator_throws_for_remove_before_next()
    {
        Mutable<name>Iterator iterator = this.classUnderTest().<type>Iterator();
        Assert.assertTrue(iterator.hasNext());
        Assert.assertThrows(UnsupportedOperationException.class, iterator::remove);
    }

    @Override
    public void <type>Iterator_throws_for_consecutive_remove()
    {
        // Not applicable for Unmodifiable
    }
}

>>

NaNTests() ::= <<
@Override
@Test(expected = UnsupportedOperationException.class)
public void add_NaN()
{
    this.newWith(<wrapperName>.NaN).add(<wrapperName>.NaN);
}

@Override
@Test(expected = UnsupportedOperationException.class)
public void add_POSITIVE_INFINITY()
{
    this.newWith(<wrapperName>.POSITIVE_INFINITY).add(<wrapperName>.POSITIVE_INFINITY);
}

@Override
@Test(expected = UnsupportedOperationException.class)
public void add_NEGATIVE_INFINITY()
{
    this.newWith(<wrapperName>.NEGATIVE_INFINITY).add(<wrapperName>.NEGATIVE_INFINITY);
}

>>
