16548Ssherman// 20020717 gdr 216673Srriggs 36548Ssherman// Copyright (C) 2002-2015 Free Software Foundation, Inc. 46548Ssherman// 56548Ssherman// This file is part of the GNU ISO C++ Library. This library is free 66548Ssherman// software; you can redistribute it and/or modify it under the 76548Ssherman// terms of the GNU General Public License as published by the 86548Ssherman// Free Software Foundation; either version 3, or (at your option) 96548Ssherman// any later version. 106548Ssherman 116548Ssherman// This library is distributed in the hope that it will be useful, 126548Ssherman// but WITHOUT ANY WARRANTY; without even the implied warranty of 136548Ssherman// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 146548Ssherman// GNU General Public License for more details. 156548Ssherman 166548Ssherman// You should have received a copy of the GNU General Public License along 176548Ssherman// with this library; see the file COPYING3. If not see 186548Ssherman// <http://www.gnu.org/licenses/>. 196548Ssherman 206548Ssherman// Test slice class invariants 216548Ssherman 226548Ssherman#include <valarray> 236548Ssherman#include <cstdlib> 246548Ssherman#include <testsuite_hooks.h> 256548Ssherman 266548Sshermanbool 276548Sshermanconstruction(std::size_t start, std::size_t size, std::size_t stride) 286548Ssherman{ 296548Ssherman std::slice s(start, size, stride); 306548Ssherman return s.start() == start && s.size() == size && s.stride() == stride; 316548Ssherman} 326548Ssherman 336548Sshermanbool 346548Sshermancopy(std::size_t start, std::size_t size, std::size_t stride) 356548Ssherman{ 366548Ssherman std::slice s(start, size, stride); 376548Ssherman std::slice t = s; 386548Ssherman return t.start() == start && t.size() == size && t.stride() == stride; 396548Ssherman} 406548Ssherman 416548Sshermanbool 426548Sshermanassignment(std::size_t start, std::size_t size, std::size_t stride) 436548Ssherman{ 446548Ssherman std::slice s(start, size, stride); 456548Ssherman std::slice t; 466548Ssherman t = s; 476548Ssherman return t.start() == start && t.size() == size && t.stride() == stride; 486548Ssherman} 496548Ssherman 506548Ssherman 516548Sshermanint main() 526548Ssherman{ 536548Ssherman bool test __attribute__((unused)) = true; 546548Ssherman std::srand(20020717); 556548Ssherman using std::rand; 566548Ssherman VERIFY(construction(rand(), rand(), rand())); 576548Ssherman 586548Ssherman VERIFY(copy(rand(), rand(), rand())); 596548Ssherman 606548Ssherman VERIFY(assignment(rand(), rand(), rand())); 616548Ssherman 626548Ssherman return 0; 636548Ssherman} 646548Ssherman