ReactOS 0.4.15-dev-8058-ga7cbb60
logic_test.cpp
Go to the documentation of this file.
1#include <vector>
2#include <algorithm>
3#include <functional>
4
6
7#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
8using namespace std;
9#endif
10
11//
12// TestCase class
13//
14class LogicTest : public CPPUNIT_NS::TestCase
15{
21
22protected:
23 void logicand();
24 void logicnot();
25 void logicor();
26};
27
29
30//
31// tests implementation
32//
34{
35 bool input1 [4] = { true, true, false, true };
36 bool input2 [4] = { false, true, false, false };
37
38 bool output [4];
39 transform((bool*)input1, (bool*)input1 + 4, (bool*)input2, (bool*)output, logical_and<bool>());
40
41 CPPUNIT_ASSERT(output[0]==false);
42 CPPUNIT_ASSERT(output[1]==true);
43 CPPUNIT_ASSERT(output[2]==false);
44 CPPUNIT_ASSERT(output[3]==false);
45}
47{
48 bool input [7] = { 1, 0, 0, 1, 1, 1, 1 };
49
50 int n = count_if(input, input + 7, logical_not<bool>());
51 CPPUNIT_ASSERT( n == 2 );
52}
54{
55 bool input1 [4] = { true, true, false, true };
56 bool input2 [4] = { false, true, false, false };
57
58 bool output [4];
59 transform((bool*)input1, (bool*)input1 + 4, (bool*)input2, (bool*)output, logical_or<bool>());
60
61 CPPUNIT_ASSERT(output[0]==true);
62 CPPUNIT_ASSERT(output[1]==true);
63 CPPUNIT_ASSERT(output[2]==false);
64 CPPUNIT_ASSERT(output[3]==true);
65}
_STLP_INLINE_LOOP void count_if(_InputIter __first, _InputIter __last, _Predicate __pred, _Size &__n)
Definition: _algo.h:115
CPPUNIT_TEST(logicnot)
void logicnot()
Definition: logic_test.cpp:46
CPPUNIT_TEST(logicand)
CPPUNIT_TEST_SUITE(LogicTest)
void logicor()
Definition: logic_test.cpp:53
void logicand()
Definition: logic_test.cpp:33
CPPUNIT_TEST(logicor)
CPPUNIT_TEST_SUITE_END()
#define CPPUNIT_TEST_SUITE_REGISTRATION(X)
Definition: cppunit_mini.h:193
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
GLdouble n
Definition: glext.h:7729
GLuint GLenum GLenum transform
Definition: glext.h:9407
GLenum GLenum GLenum input
Definition: glext.h:9031
Definition: features.h:417