]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/26_numerics/valarray_operators.cc
locale_facets.tcc: Tweak to avoid warnings.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 26_numerics / valarray_operators.cc
CommitLineData
847e8c74
VR
1// { dg-do run }
2// 2003-02-03 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
3
4// Copyright (C) 2003 Free Software Foundation
5//
6// This file is part of the GNU ISO C++ Library. This library is free
7// software; you can redistribute it and/or modify it under the
8// terms of the GNU General Public License as published by the
9// Free Software Foundation; either version 2, or (at your option)
10// any later version.
11
12// This library is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16
17// You should have received a copy of the GNU General Public License along
18// with this library; see the file COPYING. If not, write to the Free
19// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20// USA.
21
22#include <valarray>
23#include <testsuite_hooks.h>
24
25void test01() // check unary operators
26{
11f10e6b 27 bool test __attribute__((unused)) = true;
847e8c74
VR
28 std::valarray<int> u(1);
29 u[0]=1;
30
31 VERIFY( (+u)[0] == +1 );
32 VERIFY( (-u)[0] == -1 );
33 VERIFY( (!u)[0] == !1 );
34 VERIFY( (~u)[0] == ~1 );
35}
36
37void test02() // check binary operators
38{
11f10e6b 39 bool test __attribute__((unused)) = true;
847e8c74
VR
40 std::valarray<int> u(1), v(1);
41 u[0]=1;
42 v[0]=3;
43
44 VERIFY( (u+ v)[0] == (1+ 3) );
45 VERIFY( (u- v)[0] == (1- 3) );
46 VERIFY( (u* v)[0] == (1* 3) );
47 VERIFY( (u/ v)[0] == (1/ 3) );
48 VERIFY( (u% v)[0] == (1% 3) );
49 VERIFY( (u^ v)[0] == (1^ 3) );
50 VERIFY( (u& v)[0] == (1& 3) );
51 VERIFY( (u| v)[0] == (1| 3) );
52 VERIFY( (u<<v)[0] == (1<<3) );
53 VERIFY( (u>>v)[0] == (1>>3) );
54 VERIFY( (u&&v)[0] == (1&&3) );
55 VERIFY( (u||v)[0] == (1||3) );
56 VERIFY( (u==v)[0] == (1==3) );
57 VERIFY( (u!=v)[0] == (1!=3) );
58 VERIFY( (u< v)[0] == (1< 3) );
59 VERIFY( (u> v)[0] == (1> 3) );
60 VERIFY( (u<=v)[0] == (1<=3) );
61 VERIFY( (u>=v)[0] == (1>=3) );
62}
63
64int main()
65{
66 test01();
67 test02();
68 return 0;
69}