aboutsummaryrefslogtreecommitdiff
path: root/test/unit/valarray_test.cpp
blob: 87ee3dc4b08b050a0dd78603782722df94273ad5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include <valarray>

#include "cppunit/cppunit_proxy.h"

#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
using namespace std;
#endif

//
// TestCase class
//
class ValarrayTest : public CPPUNIT_NS::TestCase
{
  CPPUNIT_TEST_SUITE(ValarrayTest);
  CPPUNIT_TEST(transcendentals);
  CPPUNIT_TEST_SUITE_END();

protected:
  void transcendentals();
};

CPPUNIT_TEST_SUITE_REGISTRATION(ValarrayTest);

//
// tests implementation
//
// For the moment this test is just a complitation test
// everyone is welcome to do a real good unit test for
// valarray functionality.
void ValarrayTest::transcendentals()
{
#ifdef __SUNPRO_CC
  using std::abs;
#endif
  {
    valarray<double> darray;
    valarray<double> tmp;
    tmp = abs(darray);
    tmp = acos(darray);
    tmp = asin(darray);
    tmp = atan(darray);
    tmp = atan2(darray, tmp);
    tmp = atan2(1.0, darray);
    tmp = atan2(darray, 1.0);
    tmp = cos(darray);
    tmp = cosh(darray);
    tmp = sin(darray);
    tmp = sinh(darray);
    tmp = tan(darray);
#if !defined (STLPORT) || !defined (_STLP_USING_PLATFORM_SDK_COMPILER) || !defined (_M_AMD64)
    tmp = tanh(darray);
#endif
    tmp = exp(darray);
    tmp = log(darray);
    tmp = log10(darray);
    tmp = pow(darray, tmp);
    tmp = pow(1.0, darray);
    tmp = pow(darray, 1.0);
    tmp = sqrt(darray);
  }
  {
    valarray<float> farray;
    valarray<float> tmp;
    tmp = abs(farray);
    tmp = acos(farray);
    tmp = asin(farray);
    tmp = atan(farray);
    tmp = atan2(farray, tmp);
    tmp = atan2(1.0f, farray);
    tmp = atan2(farray, 1.0f);
    tmp = cos(farray);
    tmp = cosh(farray);
    tmp = sin(farray);
    tmp = sinh(farray);
    tmp = tan(farray);
#if !defined (STLPORT) || !defined (_STLP_USING_PLATFORM_SDK_COMPILER) || !defined (_M_AMD64)
    tmp = tanh(farray);
#endif
    tmp = exp(farray);
    tmp = log(farray);
    tmp = log10(farray);
    tmp = pow(farray, tmp);
    tmp = pow(1.0f, farray);
    tmp = pow(farray, 1.0f);
    tmp = sqrt(farray);
  }
#if !defined (STLPORT) || !defined (_STLP_NO_LONG_DOUBLE)
  {
    valarray<long double> ldarray;
    valarray<long double> tmp;
    tmp = abs(ldarray);
    tmp = acos(ldarray);
    tmp = asin(ldarray);
    tmp = atan(ldarray);
    tmp = atan2(ldarray, tmp);
    tmp = atan2(1.0l, ldarray);
    tmp = atan2(ldarray, 1.0l);
    tmp = cos(ldarray);
    tmp = cosh(ldarray);
    tmp = sin(ldarray);
    tmp = sinh(ldarray);
    tmp = tan(ldarray);
#  if !defined (STLPORT) || !defined (_STLP_USING_PLATFORM_SDK_COMPILER) || !defined (_M_AMD64)
    tmp = tanh(ldarray);
#  endif
    tmp = exp(ldarray);
    tmp = log(ldarray);
    tmp = log10(ldarray);
    tmp = pow(ldarray, tmp);
    tmp = pow(1.0l, ldarray);
    tmp = pow(ldarray, 1.0l);
    tmp = sqrt(ldarray);
  }
#endif
  valarray<double> v0(2, 10);
  valarray<double> v1(v0[slice(0, 1, 5)]);
  v0[slice(0, 1, 5)] = 5;
  valarray<double> v2(v0[gslice()]);
  //valarray<double> v3(v0[valarray<bool>()]);
  valarray<double> v4(v0[valarray<size_t>()]);
}