Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenlogic_test.cpp
Go to the documentation of this file.
00001 #include <vector> 00002 #include <algorithm> 00003 #include <functional> 00004 00005 #include "cppunit/cppunit_proxy.h" 00006 00007 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES) 00008 using namespace std; 00009 #endif 00010 00011 // 00012 // TestCase class 00013 // 00014 class LogicTest : public CPPUNIT_NS::TestCase 00015 { 00016 CPPUNIT_TEST_SUITE(LogicTest); 00017 CPPUNIT_TEST(logicand); 00018 CPPUNIT_TEST(logicnot); 00019 CPPUNIT_TEST(logicor); 00020 CPPUNIT_TEST_SUITE_END(); 00021 00022 protected: 00023 void logicand(); 00024 void logicnot(); 00025 void logicor(); 00026 }; 00027 00028 CPPUNIT_TEST_SUITE_REGISTRATION(LogicTest); 00029 00030 // 00031 // tests implementation 00032 // 00033 void LogicTest::logicand() 00034 { 00035 bool input1 [4] = { true, true, false, true }; 00036 bool input2 [4] = { false, true, false, false }; 00037 00038 bool output [4]; 00039 transform((bool*)input1, (bool*)input1 + 4, (bool*)input2, (bool*)output, logical_and<bool>()); 00040 00041 CPPUNIT_ASSERT(output[0]==false); 00042 CPPUNIT_ASSERT(output[1]==true); 00043 CPPUNIT_ASSERT(output[2]==false); 00044 CPPUNIT_ASSERT(output[3]==false); 00045 } 00046 void LogicTest::logicnot() 00047 { 00048 bool input [7] = { 1, 0, 0, 1, 1, 1, 1 }; 00049 00050 int n = count_if(input, input + 7, logical_not<bool>()); 00051 CPPUNIT_ASSERT( n == 2 ); 00052 } 00053 void LogicTest::logicor() 00054 { 00055 bool input1 [4] = { true, true, false, true }; 00056 bool input2 [4] = { false, true, false, false }; 00057 00058 bool output [4]; 00059 transform((bool*)input1, (bool*)input1 + 4, (bool*)input2, (bool*)output, logical_or<bool>()); 00060 00061 CPPUNIT_ASSERT(output[0]==true); 00062 CPPUNIT_ASSERT(output[1]==true); 00063 CPPUNIT_ASSERT(output[2]==false); 00064 CPPUNIT_ASSERT(output[3]==true); 00065 } Generated on Thu May 24 2012 04:35:56 for ReactOS by
1.7.6.1
|