|
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 #include <algorithm> |
|
18 #include "unary.h" |
|
19 |
|
20 #include "cppunit/cppunit_proxy.h" |
|
21 |
|
22 #if defined(_STLP_USE_NAMESPACES) |
|
23 using namespace std; |
|
24 #endif |
|
25 |
|
26 // |
|
27 // TestCase class |
|
28 // |
|
29 class BcomposTest : public CPPUNIT_NS::TestCase |
|
30 { |
|
31 CPPUNIT_TEST_SUITE(BcomposTest); |
|
32 #if !defined (STLPORT) || defined (_STLP_NO_EXTENSIONS) |
|
33 CPPUNIT_IGNORE; |
|
34 #endif |
|
35 CPPUNIT_TEST(bcompos1); |
|
36 CPPUNIT_TEST(bcompos2); |
|
37 CPPUNIT_TEST_SUITE_END(); |
|
38 |
|
39 protected: |
|
40 void bcompos1(); |
|
41 void bcompos2(); |
|
42 }; |
|
43 |
|
44 CPPUNIT_TEST_SUITE_REGISTRATION(BcomposTest); |
|
45 |
|
46 // |
|
47 // tests implementation |
|
48 // |
|
49 void BcomposTest::bcompos1() |
|
50 { |
|
51 #if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS) |
|
52 int array [6] = { -2, -1, 0, 1, 2, 3 }; |
|
53 |
|
54 binary_compose<logical_and<bool>, odd, positive> |
|
55 b = binary_compose<logical_and<bool>, odd, positive>(logical_and<bool>(), odd(), positive()); |
|
56 |
|
57 int* p = find_if((int*)array, (int*)array + 6, b); |
|
58 CPPUNIT_ASSERT(p != array + 6); |
|
59 #endif |
|
60 } |
|
61 |
|
62 void BcomposTest::bcompos2() |
|
63 { |
|
64 #if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS) |
|
65 int array [6] = { -2, -1 , 0, 1, 2, 3 }; |
|
66 |
|
67 int* p = find_if((int*)array, (int*)array + 6, |
|
68 compose2(logical_and<bool>(), odd(), positive())); |
|
69 CPPUNIT_ASSERT(p != array + 6); |
|
70 #endif |
|
71 } |