<?xml version="1.0"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You 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

      https://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.
-->
<project xmlns:au="antlib:org.apache.ant.antunit" default="antunit">

  <import file="../../antunit-base.xml" />

  <tokens id="testrc">
    <string value="1,2,3,4,5" />
    <stringtokenizer delims="," />
  </tokens>

  <target name="testfirst0">
    <au:assertTrue>
      <resourcecount count="0">
        <first count="0"><resources refid="testrc" /></first>
      </resourcecount>
    </au:assertTrue>
  </target>

  <target name="testfirst1">
    <au:assertTrue>
      <resourcecount count="0">
        <difference>
          <first><resources refid="testrc" /></first>
          <string value="1" />
        </difference>
      </resourcecount>
    </au:assertTrue>
  </target>

  <target name="testfirst2">
    <au:assertTrue>
      <resourcecount count="0">
        <difference>
          <first count="2"><resources refid="testrc" /></first>
          <resources>
            <string value="1" />
            <string value="2" />
          </resources>
        </difference>
      </resourcecount>
    </au:assertTrue>
  </target>

  <target name="testfirst5">
    <au:assertTrue>
      <resourcecount count="0">
        <difference>
          <first count="5"><resources refid="testrc" /></first>
          <resources refid="testrc" />
        </difference>
      </resourcecount>
    </au:assertTrue>
  </target>

  <target name="testfirst6">
    <au:assertTrue>
      <resourcecount count="0">
        <difference>
          <first count="6"><resources refid="testrc" /></first>
          <resources refid="testrc" />
        </difference>
      </resourcecount>
    </au:assertTrue>
  </target>

  <target name="testfirst-1">
    <au:expectfailure expectedmessage="size-limited collection count should be set to an int &gt;= 0">
      <resourcecount>
        <first count="-1"><resources refid="testrc" /></first>
      </resourcecount>
    </au:expectfailure>
  </target>

  <target name="testlast0">
    <au:assertTrue>
      <resourcecount count="0">
        <last count="0"><resources refid="testrc" /></last>
      </resourcecount>
    </au:assertTrue>
  </target>

  <target name="testlast1">
    <au:assertTrue>
      <resourcecount count="0">
        <difference>
          <last><resources refid="testrc" /></last>
          <string value="5" />
        </difference>
      </resourcecount>
    </au:assertTrue>
  </target>

  <target name="testlast2">
    <au:assertTrue>
      <resourcecount count="0">
        <difference>
          <last count="2"><resources refid="testrc" /></last>
          <resources>
            <string value="4" />
            <string value="5" />
          </resources>
        </difference>
      </resourcecount>
    </au:assertTrue>
  </target>

  <target name="testlast5">
    <au:assertTrue>
      <resourcecount count="0">
        <difference>
          <last count="5"><resources refid="testrc" /></last>
          <resources refid="testrc" />
        </difference>
      </resourcecount>
    </au:assertTrue>
  </target>

  <target name="testlast6">
    <au:assertTrue>
      <resourcecount count="0">
        <difference>
          <last count="6"><resources refid="testrc" /></last>
          <resources refid="testrc" />
        </difference>
      </resourcecount>
    </au:assertTrue>
  </target>

  <target name="testlast-1">
    <au:expectfailure expectedmessage="size-limited collection count should be set to an int &gt;= 0">
      <resourcecount>
        <last count="-1"><resources refid="testrc" /></last>
      </resourcecount>
    </au:expectfailure>
  </target>

  <target name="testallbutfirst5">
    <au:assertTrue>
      <resourcecount count="0">
        <allbutfirst count="5"><resources refid="testrc" /></allbutfirst>
      </resourcecount>
    </au:assertTrue>
  </target>

  <target name="testallbutfirst4">
    <au:assertTrue>
      <resourcecount count="0">
        <difference>
          <allbutfirst count="4"><resources refid="testrc" /></allbutfirst>
          <string value="5" />
        </difference>
      </resourcecount>
    </au:assertTrue>
  </target>

  <target name="testallbutfirst3">
    <au:assertTrue>
      <resourcecount count="0">
        <difference>
          <allbutfirst count="3"><resources refid="testrc" /></allbutfirst>
          <resources>
            <string value="4" />
            <string value="5" />
          </resources>
        </difference>
      </resourcecount>
    </au:assertTrue>
  </target>

  <target name="testallbutfirst">
    <au:assertTrue>
      <resourcecount count="0">
        <difference>
          <allbutfirst><resources refid="testrc" /></allbutfirst>
          <resources>
            <string value="2" />
            <string value="3" />
            <string value="4" />
            <string value="5" />
          </resources>
        </difference>
      </resourcecount>
    </au:assertTrue>
  </target>

  <target name="testallbutfirst6">
    <au:assertTrue>
      <resourcecount count="0">
        <allbutfirst count="6"><resources refid="testrc" /></allbutfirst>
      </resourcecount>
    </au:assertTrue>
  </target>

  <target name="testallbutfirst-1">
    <au:expectfailure expectedmessage="size-limited collection count should be set to an int &gt;= 0">
      <resourcecount>
        <allbutfirst count="-1"><resources refid="testrc" /></allbutfirst>
      </resourcecount>
    </au:expectfailure>
  </target>

  <target name="testallbutlast5">
    <au:assertTrue>
      <resourcecount count="0">
        <allbutlast count="5"><resources refid="testrc" /></allbutlast>
      </resourcecount>
    </au:assertTrue>
  </target>

  <target name="testallbutlast4">
    <au:assertTrue>
      <resourcecount count="0">
        <difference>
          <allbutlast count="4"><resources refid="testrc" /></allbutlast>
          <string value="1" />
        </difference>
      </resourcecount>
    </au:assertTrue>
  </target>

  <target name="testallbutlast1">
    <au:assertTrue>
      <resourcecount count="0">
        <difference>
          <allbutlast><resources refid="testrc" /></allbutlast>
          <resources>
            <string value="1" />
            <string value="2" />
            <string value="3" />
            <string value="4" />
          </resources>
        </difference>
      </resourcecount>
    </au:assertTrue>
  </target>

  <target name="testallbutlast0">
    <au:assertTrue>
      <resourcecount count="0">
        <difference>
          <allbutlast count="0"><resources refid="testrc" /></allbutlast>
          <resources refid="testrc" />
        </difference>
      </resourcecount>
    </au:assertTrue>
  </target>

  <target name="testallbutlast6">
    <au:assertTrue>
      <resourcecount count="0">
        <allbutlast count="6"><resources refid="testrc" /></allbutlast>
      </resourcecount>
    </au:assertTrue>
  </target>

  <target name="testallbutlast-1">
    <au:expectfailure expectedmessage="size-limited collection count should be set to an int &gt;= 0">
      <resourcecount>
        <allbutlast count="-1"><resources refid="testrc" /></allbutlast>
      </resourcecount>
    </au:expectfailure>
  </target>

</project>
