OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / ndk / tests / device / test-stlport / unit / valarray_test.cpp
1 #include <valarray>
2
3 #include "cppunit/cppunit_proxy.h"
4
5 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
6 using namespace std;
7 #endif
8
9 //
10 // TestCase class
11 //
12 class ValarrayTest : public CPPUNIT_NS::TestCase
13 {
14   CPPUNIT_TEST_SUITE(ValarrayTest);
15   CPPUNIT_TEST(transcendentals);
16   CPPUNIT_TEST_SUITE_END();
17
18 protected:
19   void transcendentals();
20 };
21
22 CPPUNIT_TEST_SUITE_REGISTRATION(ValarrayTest);
23
24 //
25 // tests implementation
26 //
27 // For the moment this test is just a complitation test
28 // everyone is welcome to do a real good unit test for
29 // valarray functionality.
30 void ValarrayTest::transcendentals()
31 {
32 #ifdef __SUNPRO_CC
33   using std::abs;
34 #endif
35   {
36     valarray<double> darray;
37     valarray<double> tmp;
38     tmp = abs(darray);
39     tmp = acos(darray);
40     tmp = asin(darray);
41     tmp = atan(darray);
42     tmp = atan2(darray, tmp);
43     tmp = atan2(1.0, darray);
44     tmp = atan2(darray, 1.0);
45     tmp = cos(darray);
46     tmp = cosh(darray);
47     tmp = sin(darray);
48     tmp = sinh(darray);
49     tmp = tan(darray);
50 #if !defined (STLPORT) || !defined (_STLP_USING_PLATFORM_SDK_COMPILER) || !defined (_M_AMD64)
51     tmp = tanh(darray);
52 #endif
53     tmp = exp(darray);
54     tmp = log(darray);
55     tmp = log10(darray);
56     tmp = pow(darray, tmp);
57     tmp = pow(1.0, darray);
58     tmp = pow(darray, 1.0);
59     tmp = sqrt(darray);
60   }
61   {
62     valarray<float> farray;
63     valarray<float> tmp;
64     tmp = abs(farray);
65     tmp = acos(farray);
66     tmp = asin(farray);
67     tmp = atan(farray);
68     tmp = atan2(farray, tmp);
69     tmp = atan2(1.0f, farray);
70     tmp = atan2(farray, 1.0f);
71     tmp = cos(farray);
72     tmp = cosh(farray);
73     tmp = sin(farray);
74     tmp = sinh(farray);
75     tmp = tan(farray);
76 #if !defined (STLPORT) || !defined (_STLP_USING_PLATFORM_SDK_COMPILER) || !defined (_M_AMD64)
77     tmp = tanh(farray);
78 #endif
79     tmp = exp(farray);
80     tmp = log(farray);
81     tmp = log10(farray);
82     tmp = pow(farray, tmp);
83     tmp = pow(1.0f, farray);
84     tmp = pow(farray, 1.0f);
85     tmp = sqrt(farray);
86   }
87 #if !defined (STLPORT) || !defined (_STLP_NO_LONG_DOUBLE)
88   {
89     valarray<long double> ldarray;
90     valarray<long double> tmp;
91     tmp = abs(ldarray);
92     tmp = acos(ldarray);
93     tmp = asin(ldarray);
94     tmp = atan(ldarray);
95     tmp = atan2(ldarray, tmp);
96     tmp = atan2(1.0l, ldarray);
97     tmp = atan2(ldarray, 1.0l);
98     tmp = cos(ldarray);
99     tmp = cosh(ldarray);
100     tmp = sin(ldarray);
101     tmp = sinh(ldarray);
102     tmp = tan(ldarray);
103 #  if !defined (STLPORT) || !defined (_STLP_USING_PLATFORM_SDK_COMPILER) || !defined (_M_AMD64)
104     tmp = tanh(ldarray);
105 #  endif
106     tmp = exp(ldarray);
107     tmp = log(ldarray);
108     tmp = log10(ldarray);
109     tmp = pow(ldarray, tmp);
110     tmp = pow(1.0l, ldarray);
111     tmp = pow(ldarray, 1.0l);
112     tmp = sqrt(ldarray);
113   }
114 #endif
115   valarray<double> v0(2, 10);
116   valarray<double> v1(v0[slice(0, 1, 5)]);
117   v0[slice(0, 1, 5)] = 5;
118   valarray<double> v2(v0[gslice()]);
119   //valarray<double> v3(v0[valarray<bool>()]);
120   valarray<double> v4(v0[valarray<size_t>()]);
121 }