|
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 |
|
21 #include <algorithm> |
|
22 #include <iostream> |
|
23 #include <cstring> |
|
24 #include <iterator> |
|
25 #include <functional> |
|
26 |
|
27 #ifdef MAIN |
|
28 #define setdiff2_test main |
|
29 #endif |
|
30 |
|
31 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES) |
|
32 using namespace std; |
|
33 #endif |
|
34 int setdiff2_test(int, char**) |
|
35 { |
|
36 int failures=0; |
|
37 |
|
38 cout<<"Results of setdiff2_test:"<<endl; |
|
39 char* word1 = "ABCDEFGHIJKLMNO"; |
|
40 char* word2 = "LMNOPQRSTUVWXYZ"; |
|
41 char word3[12]; |
|
42 ostream_iterator <char> iter(cout, " "); |
|
43 cout << "word1: "; |
|
44 copy(word1, word1 + ::strlen(word1), iter); |
|
45 |
|
46 if(strcmp(word1,"ABCDEFGHIJKLMNO")) |
|
47 failures++; |
|
48 |
|
49 cout << "\nword2: "; |
|
50 copy(word2, word2 + ::strlen(word2), iter); |
|
51 cout << endl; |
|
52 |
|
53 if(strcmp(word2,"LMNOPQRSTUVWXYZ")) |
|
54 failures++; |
|
55 |
|
56 set_difference(word1, word1 + ::strlen(word1), |
|
57 word2, word2 + ::strlen(word2), |
|
58 word3, |
|
59 less<char>()); |
|
60 |
|
61 word3[11]='\0'; |
|
62 int x=strcmp(word3,"ABCDEFGHIJK"); |
|
63 if(x) |
|
64 failures++; |
|
65 |
|
66 copy(word3,word3 + ::strlen(word3),iter); |
|
67 |
|
68 cout << endl; |
|
69 |
|
70 if(failures) |
|
71 return 1; |
|
72 else |
|
73 return 0; |
|
74 } |
|
75 |