1 // 20020717 gdr
2 
3 // Copyright (C) 2002 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library.  This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
9 // any later version.
10 
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15 
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING.  If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 // USA.
20 
21 // Test slice class invariants
22 
23 #include <valarray>
24 #include <cstdlib>
25 #include <testsuite_hooks.h>
26 
27 bool
construction(int start,int size,int stride)28 construction(int start, int size, int stride)
29 {
30   std::slice s(start, size, stride);
31   return s.start() == start && s.size() == size && s.stride() == stride;
32 }
33 
34 bool
copy(int start,int size,int stride)35 copy(int start, int size, int stride)
36 {
37   std::slice s(start, size, stride);
38   std::slice t = s;
39   return t.start() == start && t.size() == size && t.stride() == stride;
40 }
41 
42 bool
assignment(int start,int size,int stride)43 assignment(int start, int size, int stride)
44 {
45   std::slice s(start, size, stride);
46   std::slice t;
47   t = s;
48   return t.start() == start && t.size() == size && t.stride() == stride;
49 }
50 
51 
main()52 int main()
53 {
54   std::srand(20020717);         using std::rand;
55   VERIFY(construction(rand(), rand(), rand()));
56 
57   VERIFY(copy(rand(), rand(), rand()));
58 
59   VERIFY(assignment(rand(), rand(), rand()));
60 
61   return 0;
62 }
63