import "copyright.stg"
import "primitiveHashCode.stg"
import "primitiveLiteral.stg"

isTest() ::= "true"

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

fileName(primitive) ::= "<primitive.name>ArrayStackTest"

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

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

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

import org.eclipse.collections.api.<name>Iterable;
import org.eclipse.collections.api.RichIterable;
import org.eclipse.collections.api.stack.primitive.Mutable<name>Stack;
import org.eclipse.collections.impl.factory.primitive.<name>Stacks;
import org.eclipse.collections.impl.list.mutable.primitive.<name>ArrayList;
import org.eclipse.collections.impl.stack.mutable.ArrayStack;
import org.eclipse.collections.impl.test.Verify;
import org.junit.Assert;
import org.junit.Test;

/**
 * JUnit test for {@link <name>ArrayStack}.
 * This file was automatically generated from template file primitiveArrayStackTest.stg.
 */
public class <name>ArrayStackTest extends AbstractMutable<name>StackTestCase
{
    @Override
    protected Mutable<name>Stack classUnderTest()
    {
        return <name>ArrayStack.newStackWith(<["1", "2", "3"]:(literal.(type))(); separator=", ">);
    }

    @Override
    protected Mutable<name>Stack newWith(<type>... elements)
    {
        return <name>ArrayStack.newStackWith(elements);
    }

    @Override
    protected Mutable<name>Stack newMutableCollectionWith(<type>... elements)
    {
        return <name>ArrayStack.newStackWith(elements);
    }

    @Override
    protected Mutable<name>Stack newWithTopToBottom(<type>... elements)
    {
        return <name>ArrayStack.newStackFromTopToBottom(elements);
    }

    @Override
    protected Mutable<name>Stack newWithIterableTopToBottom(<name>Iterable iterable)
    {
        return <name>ArrayStack.newStackFromTopToBottom(iterable);
    }

    @Override
    protected Mutable<name>Stack newWithIterable(<name>Iterable iterable)
    {
        return <name>ArrayStack.newStack(iterable);
    }

    @Override
    protected RichIterable\<<wrapperName>\> newObjectCollectionWith(<wrapperName>... elements)
    {
        return ArrayStack.newStackWith(elements);
    }

    @Test
    public void testPushPopAndPeek()
    {
        <name>ArrayStack stack = <name>ArrayStack.newStackFromTopToBottom();
        stack.push(<["1"]:(literal.(type))(); separator=", ">);
        Assert.assertEquals(<["1"]:(literal.(type))(); separator=", ">, stack.peek()<(delta.(type))>);
        Assert.assertEquals(<name>ArrayStack.newStackFromTopToBottom(<["1"]:(literal.(type))(); separator=", ">), stack);

        stack.push(<["2"]:(literal.(type))(); separator=", ">);
        Assert.assertEquals(<["2"]:(literal.(type))(); separator=", ">, stack.peek()<(delta.(type))>);
        Assert.assertEquals(<name>ArrayStack.newStackFromTopToBottom(<["2"]:(literal.(type))(); separator=", ">, <["1"]:(literal.(type))(); separator=", ">), stack);

        stack.push(<["3"]:(literal.(type))(); separator=", ">);
        Assert.assertEquals(<["3"]:(literal.(type))(); separator=", ">, stack.peek()<(delta.(type))>);
        Assert.assertEquals(<name>ArrayStack.newStackFromTopToBottom(<["3"]:(literal.(type))(); separator=", ">, <["2"]:(literal.(type))(); separator=", ">, <["1"]:(literal.(type))(); separator=", ">), stack);

        Assert.assertEquals(<["2"]:(literal.(type))(); separator=", ">, stack.peekAt(1)<(delta.(type))>);
        Assert.assertEquals(<["3"]:(literal.(type))(); separator=", ">, stack.pop()<(delta.(type))>);
        Assert.assertEquals(<["2"]:(literal.(type))(); separator=", ">, stack.peek()<(delta.(type))>);
        Assert.assertEquals(<["2"]:(literal.(type))(); separator=", ">, stack.pop()<(delta.(type))>);
        Assert.assertEquals(<["1"]:(literal.(type))(); separator=", ">, stack.peek()<(delta.(type))>);
        Assert.assertEquals(<["1"]:(literal.(type))(); separator=", ">, stack.pop()<(delta.(type))>);

        <name>ArrayStack stack2 = <name>ArrayStack.newStackFromTopToBottom(<["5"]:(literal.(type))(); separator=", ">, <["4"]:(literal.(type))(); separator=", ">, <["3"]:(literal.(type))(); separator=", ">, <["2"]:(literal.(type))(); separator=", ">, <["1"]:(literal.(type))(); separator=", ">);
        stack2.pop(2);
        Assert.assertEquals(<name>ArrayStack.newStackFromTopToBottom(<["3"]:(literal.(type))(); separator=", ">, <["2"]:(literal.(type))(); separator=", ">, <["1"]:(literal.(type))(); separator=", ">), stack2);
        Assert.assertEquals(<name>ArrayList.newListWith(<["3"]:(literal.(type))(); separator=", ">, <["2"]:(literal.(type))(); separator=", ">), stack2.peek(2));

        <name>ArrayStack stack8 = <name>ArrayStack.newStackFromTopToBottom(<["1"]:(literal.(type))(); separator=", ">, <["2"]:(literal.(type))(); separator=", ">, <["3"]:(literal.(type))(); separator=", ">, <["4"]:(literal.(type))(); separator=", ">);
        Verify.assertSize(0, stack8.pop(0));
        Assert.assertEquals(<name>ArrayStack.newStackFromTopToBottom(<["1"]:(literal.(type))(); separator=", ">, <["2"]:(literal.(type))(); separator=", ">, <["3"]:(literal.(type))(); separator=", ">, <["4"]:(literal.(type))(); separator=", ">), stack8);
        Assert.assertEquals(new <name>ArrayList(), stack8.peek(0));

        <name>ArrayStack stack9 = <name>ArrayStack.newStackFromTopToBottom();
        Assert.assertEquals(new <name>ArrayList(), stack9.pop(0));
        Assert.assertEquals(new <name>ArrayList(), stack9.peek(0));
    }

    @Test
    public void classIsNonInstantiable()
    {
        Verify.assertClassNonInstantiable(<name>Stacks.class);
    }
}

>>

