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) 8using namespace std; 9#endif 10 11// 12// TestCase class 13// 14class NeqTest : public CPPUNIT_NS::TestCase 15{ 16 CPPUNIT_TEST_SUITE(NeqTest); 17 CPPUNIT_TEST(negate0); 18 CPPUNIT_TEST(nequal0); 19 CPPUNIT_TEST_SUITE_END(); 20 21protected: 22 void negate0(); 23 void nequal0(); 24}; 25 26CPPUNIT_TEST_SUITE_REGISTRATION(NeqTest); 27 28// 29// tests implementation 30// 31void NeqTest::negate0() 32{ 33 int input [3] = { 1, 2, 3 }; 34 35 int output[3]; 36 transform((int*)input, (int*)input + 3, (int*)output, negate<int>()); 37 38 CPPUNIT_ASSERT(output[0]==-1); 39 CPPUNIT_ASSERT(output[1]==-2); 40 CPPUNIT_ASSERT(output[2]==-3); 41} 42void NeqTest::nequal0() 43{ 44 int input1 [4] = { 1, 7, 2, 2 }; 45 int input2 [4] = { 1, 6, 2, 3 }; 46 47 int output [4]; 48 transform((int*)input1, (int*)input1 + 4, (int*)input2, (int*)output, not_equal_to<int>()); 49 50 CPPUNIT_ASSERT(output[0]==0); 51 CPPUNIT_ASSERT(output[1]==1); 52 CPPUNIT_ASSERT(output[2]==0); 53 CPPUNIT_ASSERT(output[3]==1); 54} 55