equal
deleted
inserted
replaced
|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 // STLport regression testsuite component. |
|
19 // To compile as a separate example, please #define MAIN. |
|
20 #include <iterator> |
|
21 |
|
22 #include <vector> |
|
23 #include <algorithm> |
|
24 #include <iostream> |
|
25 #include <iterator> |
|
26 #include <functional> |
|
27 #include <numeric> |
|
28 |
|
29 #ifdef MAIN |
|
30 #define partsum2_test main |
|
31 #endif |
|
32 |
|
33 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES) |
|
34 using namespace std; |
|
35 #endif |
|
36 int partsum2_test(int, char**) |
|
37 { |
|
38 |
|
39 int failures=0; |
|
40 cout<<"Results of partsum2_test:"<<endl; |
|
41 vector <int> v1(5); |
|
42 iota(v1.begin(), v1.end(), 1); |
|
43 vector <int> v2(v1.size()); |
|
44 partial_sum(v1.begin(), v1.end(), v2.begin(), multiplies<int>()); |
|
45 ostream_iterator <int> iter(cout, " "); |
|
46 copy(v1.begin(), v1.end(), iter); |
|
47 cout << endl; |
|
48 |
|
49 if(1 !=v1[0]) |
|
50 failures++; |
|
51 else if(2 !=v1[1]) |
|
52 failures++; |
|
53 else if(2 !=v1[2]) |
|
54 failures++; |
|
55 else if(2 !=v1[3]) |
|
56 failures++; |
|
57 else if(2 !=v1[4]) |
|
58 failures++; |
|
59 |
|
60 copy(v2.begin(), v2.end(), iter); |
|
61 cout << endl; |
|
62 |
|
63 if(1 !=v2[0]) |
|
64 failures++; |
|
65 else if(2 !=v2[1]) |
|
66 failures++; |
|
67 else if(6 !=v2[2]) |
|
68 failures++; |
|
69 else if(24 !=v2[3]) |
|
70 failures++; |
|
71 else if(120!=v2[4]) |
|
72 failures++; |
|
73 |
|
74 return 0; |
|
75 } |
|
76 |