ReactOS  0.4.13-dev-100-gc8611ae
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)
8 using namespace std;
9 #endif
10 
11 //
12 // TestCase class
13 //
14 class LogicTest : public CPPUNIT_NS::TestCase
15 {
17  CPPUNIT_TEST(logicand);
18  CPPUNIT_TEST(logicnot);
19  CPPUNIT_TEST(logicor);
21 
22 protected:
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 }
CPPUNIT_TEST_SUITE_REGISTRATION(LogicTest)
static UCHAR ULONG UCHAR ULONG UCHAR * output
Definition: bcrypt.c:29
void logicnot()
Definition: logic_test.cpp:46
_STLP_INLINE_LOOP void count_if(_InputIter __first, _InputIter __last, _Predicate __pred, _Size &__n)
Definition: _algo.h:115
GLdouble n
Definition: glext.h:7729
#define CPPUNIT_TEST_SUITE(X)
Definition: cppunit_mini.h:142
#define CPPUNIT_TEST(X)
Definition: cppunit_mini.h:182
Definition: features.h:417
void logicand()
Definition: logic_test.cpp:33
#define CPPUNIT_TEST_SUITE_END()
Definition: cppunit_mini.h:191
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
GLenum GLenum GLenum input
Definition: glext.h:9031
void logicor()
Definition: logic_test.cpp:53
GLuint GLenum GLenum transform
Definition: glext.h:9407