ReactOS
0.4.16-dev-319-g6cf4263
logic_test.cpp
Go to the documentation of this file.
1
#include <vector>
2
#include <algorithm>
3
#include <functional>
4
5
#include "
cppunit/cppunit_proxy.h
"
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
{
16
CPPUNIT_TEST_SUITE
(
LogicTest
);
17
CPPUNIT_TEST
(
logicand
);
18
CPPUNIT_TEST
(
logicnot
);
19
CPPUNIT_TEST
(
logicor
);
20
CPPUNIT_TEST_SUITE_END
();
21
22
protected
:
23
void
logicand
();
24
void
logicnot
();
25
void
logicor
();
26
};
27
28
CPPUNIT_TEST_SUITE_REGISTRATION
(
LogicTest
);
29
30
//
31
// tests implementation
32
//
33
void
LogicTest::logicand
()
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
}
46
void
LogicTest::logicnot
()
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
}
53
void
LogicTest::logicor
()
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
}
count_if
_STLP_INLINE_LOOP void count_if(_InputIter __first, _InputIter __last, _Predicate __pred, _Size &__n)
Definition:
_algo.h:115
LogicTest
Definition:
logic_test.cpp:15
LogicTest::CPPUNIT_TEST
CPPUNIT_TEST(logicnot)
LogicTest::logicnot
void logicnot()
Definition:
logic_test.cpp:46
LogicTest::CPPUNIT_TEST
CPPUNIT_TEST(logicand)
LogicTest::CPPUNIT_TEST_SUITE
CPPUNIT_TEST_SUITE(LogicTest)
LogicTest::logicor
void logicor()
Definition:
logic_test.cpp:53
LogicTest::logicand
void logicand()
Definition:
logic_test.cpp:33
LogicTest::CPPUNIT_TEST
CPPUNIT_TEST(logicor)
LogicTest::CPPUNIT_TEST_SUITE_END
CPPUNIT_TEST_SUITE_END()
CPPUNIT_TEST_SUITE_REGISTRATION
#define CPPUNIT_TEST_SUITE_REGISTRATION(X)
Definition:
cppunit_mini.h:193
CPPUNIT_ASSERT
#define CPPUNIT_ASSERT(X)
Definition:
cppunit_mini.h:200
cppunit_proxy.h
n
GLdouble n
Definition:
glext.h:7729
transform
GLuint GLenum GLenum transform
Definition:
glext.h:9407
input
GLenum GLenum GLenum input
Definition:
glext.h:9031
std
Definition:
features.h:417
logical_and
Definition:
_function.h:79
logical_not
Definition:
_function.h:89
logical_or
Definition:
_function.h:84
sdk
lib
3rdparty
stlport
test
unit
logic_test.cpp
Generated on Wed Dec 4 2024 06:13:30 for ReactOS by
1.9.6