/*
 *  ticket-580.sli
 *
 *  This file is part of NEST.
 *
 *  Copyright (C) 2004 The NEST Initiative
 *
 *  NEST is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  NEST is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with NEST.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

/* BeginDocumentation

Name: testsuite::ticket-580 - getinterval: No error if range of array is exceeded

Synopsis: (ticket-564) run -> NEST exits if test fails

Description: 
1) This test checks whether the sli functions getinterval and Take perform Range Checks, i.e. whether they throw errors if the requested part of the interval exceeds the original array or not. 
2) Furthermore, it checks whether getinterval throws an error if negative indices are given and whether Takes does not throw an error.
3) Checks whether Take returns an empty array if n_2 < n_1

In addition, it checks whether they return the same results for a correct usage.
 
Author: Maximilian Schmidt, 2012-10-16
 */

(unittest) run
/unittest using

M_ERROR setverbosity


[0 2] Range /x Set
(Hallo) /y Set


{ 
  x [1 4] Take
} fail_or_die

{
  x [2 1] Take
  [] eq
} assert_or_die

{
  x -2 Take
  [1 2] eq
} assert_or_die

{
  x [-2 -1] Take
  [1 2] eq
} assert_or_die

{
  x 0 Take
  [] eq
} assert_or_die

{ 
  x 0 4 getinterval
} fail_or_die

{
  x -2 2 getinterval
} fail_or_die

{
  x 0 -1 getinterval
} fail_or_die


{
  y -2 2 getinterval
} fail_or_die

{
  y 0 6 getinterval
} fail_or_die

{
  y 0 -1 getinterval
} fail_or_die

{
  x [1 3] Take
  x 0 3 getinterval
  eq
} assert_or_die


endusing
