5 #include "cppunit/cppunit_proxy.h"
7 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
14 class LogicTest : public CPPUNIT_NS::TestCase
16 CPPUNIT_TEST_SUITE(LogicTest);
17 CPPUNIT_TEST(logicand);
18 CPPUNIT_TEST(logicnot);
19 CPPUNIT_TEST(logicor);
20 CPPUNIT_TEST_SUITE_END();
28 CPPUNIT_TEST_SUITE_REGISTRATION(LogicTest);
31 // tests implementation
33 void LogicTest::logicand()
35 bool input1 [4] = { true, true, false, true };
36 bool input2 [4] = { false, true, false, false };
39 transform((bool*)input1, (bool*)input1 + 4, (bool*)input2, (bool*)output, logical_and<bool>());
41 CPPUNIT_ASSERT(output[0]==false);
42 CPPUNIT_ASSERT(output[1]==true);
43 CPPUNIT_ASSERT(output[2]==false);
44 CPPUNIT_ASSERT(output[3]==false);
46 void LogicTest::logicnot()
48 bool input [7] = { 1, 0, 0, 1, 1, 1, 1 };
50 int n = count_if(input, input + 7, logical_not<bool>());
51 CPPUNIT_ASSERT( n == 2 );
53 void LogicTest::logicor()
55 bool input1 [4] = { true, true, false, true };
56 bool input2 [4] = { false, true, false, false };
59 transform((bool*)input1, (bool*)input1 + 4, (bool*)input2, (bool*)output, logical_or<bool>());
61 CPPUNIT_ASSERT(output[0]==true);
62 CPPUNIT_ASSERT(output[1]==true);
63 CPPUNIT_ASSERT(output[2]==false);
64 CPPUNIT_ASSERT(output[3]==true);