aboutsummaryrefslogtreecommitdiff
path: root/test/unit/bcompos_test.cpp
blob: d117fab21a500b3f3fbb97a5a1f3cc01ee019e00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <algorithm>
#include "unary.h"

#include "cppunit/cppunit_proxy.h"

#if defined(_STLP_USE_NAMESPACES)
using namespace std;
#endif

//
// TestCase class
//
class BcomposTest : public CPPUNIT_NS::TestCase
{
  CPPUNIT_TEST_SUITE(BcomposTest);
#if !defined (STLPORT) || defined (_STLP_NO_EXTENSIONS)
  CPPUNIT_IGNORE;
#endif
  CPPUNIT_TEST(bcompos1);
  CPPUNIT_TEST(bcompos2);
  CPPUNIT_TEST_SUITE_END();

protected:
  void bcompos1();
  void bcompos2();
};

CPPUNIT_TEST_SUITE_REGISTRATION(BcomposTest);

//
// tests implementation
//
void BcomposTest::bcompos1()
{
#if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS)
  int array [6] = { -2, -1, 0, 1, 2, 3 };

  binary_compose<logical_and<bool>, odd, positive>
  b = binary_compose<logical_and<bool>, odd, positive>(logical_and<bool>(), odd(), positive());

  int* p = find_if((int*)array, (int*)array + 6, b);
  CPPUNIT_ASSERT(p != array + 6);
#endif
}

void BcomposTest::bcompos2()
{
#if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS)
  int array [6] = { -2, -1 , 0, 1, 2, 3 };

  int* p = find_if((int*)array, (int*)array + 6,
  compose2(logical_and<bool>(), odd(), positive()));
  CPPUNIT_ASSERT(p != array + 6);
#endif
}