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 |
|
19 // STLport regression testsuite component. |
|
20 // To compile as a separate example, please #define MAIN. |
|
21 |
|
22 #include <algorithm> |
|
23 #include <iostream> |
|
24 |
|
25 #include "fadapter.h" |
|
26 |
|
27 #ifdef MAIN |
|
28 #define foreach0_test main |
|
29 #endif |
|
30 |
|
31 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES) |
|
32 using namespace std; |
|
33 #endif |
|
34 static void print(int a_) |
|
35 { |
|
36 cout << a_ << ' '; |
|
37 } |
|
38 |
|
39 int foreach0_test(int, char**) |
|
40 { |
|
41 |
|
42 cout<<"Results of foreach0_test:"<<endl; |
|
43 int failures = 0; |
|
44 |
|
45 int numbers[10] = { 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 }; |
|
46 |
|
47 for_each(numbers, numbers + 10, ptr_proc(print)); |
|
48 cout << endl; |
|
49 if(numbers[0] != 1) |
|
50 failures++; |
|
51 if(numbers[1] != 1) |
|
52 failures++; |
|
53 if(numbers[2] != 2) |
|
54 failures++; |
|
55 if(numbers[3] != 3) |
|
56 failures++; |
|
57 if(numbers[4] != 5) |
|
58 failures++; |
|
59 if(numbers[5] != 8) |
|
60 failures++; |
|
61 if(numbers[6] != 13) |
|
62 failures++; |
|
63 if(numbers[7] != 21) |
|
64 failures++; |
|
65 if(numbers[8] != 34) |
|
66 failures++; |
|
67 if(numbers[9] != 55) |
|
68 failures++; |
|
69 return failures; |
|
70 } |