os/ossrv/genericopenlibs/cppstdlib/stl/test/unit/bcompos_test.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
#include <algorithm>
sl@0
     2
#include "unary.h"
sl@0
     3
sl@0
     4
#include "cppunit/cppunit_proxy.h"
sl@0
     5
sl@0
     6
#if defined(_STLP_USE_NAMESPACES)
sl@0
     7
using namespace std;
sl@0
     8
#endif
sl@0
     9
sl@0
    10
//
sl@0
    11
// TestCase class
sl@0
    12
//
sl@0
    13
class BcomposTest : public CPPUNIT_NS::TestCase
sl@0
    14
{
sl@0
    15
  CPPUNIT_TEST_SUITE(BcomposTest);
sl@0
    16
#if !defined (STLPORT) || defined (_STLP_NO_EXTENSIONS)
sl@0
    17
  CPPUNIT_IGNORE;
sl@0
    18
#endif
sl@0
    19
  CPPUNIT_TEST(bcompos1);
sl@0
    20
  CPPUNIT_TEST(bcompos2);
sl@0
    21
  CPPUNIT_TEST_SUITE_END();
sl@0
    22
sl@0
    23
protected:
sl@0
    24
  void bcompos1();
sl@0
    25
  void bcompos2();
sl@0
    26
};
sl@0
    27
sl@0
    28
CPPUNIT_TEST_SUITE_REGISTRATION(BcomposTest);
sl@0
    29
sl@0
    30
//
sl@0
    31
// tests implementation
sl@0
    32
//
sl@0
    33
void BcomposTest::bcompos1()
sl@0
    34
{
sl@0
    35
#if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS)
sl@0
    36
  int array [6] = { -2, -1, 0, 1, 2, 3 };
sl@0
    37
sl@0
    38
  binary_compose<logical_and<bool>, odd, positive>
sl@0
    39
  b = binary_compose<logical_and<bool>, odd, positive>(logical_and<bool>(), odd(), positive());
sl@0
    40
sl@0
    41
  int* p = find_if((int*)array, (int*)array + 6, b);
sl@0
    42
  CPPUNIT_ASSERT(p != array + 6);
sl@0
    43
#endif
sl@0
    44
}
sl@0
    45
sl@0
    46
void BcomposTest::bcompos2()
sl@0
    47
{
sl@0
    48
#if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS)
sl@0
    49
  int array [6] = { -2, -1 , 0, 1, 2, 3 };
sl@0
    50
sl@0
    51
  int* p = find_if((int*)array, (int*)array + 6,
sl@0
    52
  compose2(logical_and<bool>(), odd(), positive()));
sl@0
    53
  CPPUNIT_ASSERT(p != array + 6);
sl@0
    54
#endif
sl@0
    55
}