1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cppstdlib/stl/test/unit/neq_test.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,54 @@
1.4 +#include <vector>
1.5 +#include <algorithm>
1.6 +#include <functional>
1.7 +
1.8 +#include "cppunit/cppunit_proxy.h"
1.9 +
1.10 +#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
1.11 +using namespace std;
1.12 +#endif
1.13 +
1.14 +//
1.15 +// TestCase class
1.16 +//
1.17 +class NeqTest : public CPPUNIT_NS::TestCase
1.18 +{
1.19 + CPPUNIT_TEST_SUITE(NeqTest);
1.20 + CPPUNIT_TEST(negate0);
1.21 + CPPUNIT_TEST(nequal0);
1.22 + CPPUNIT_TEST_SUITE_END();
1.23 +
1.24 +protected:
1.25 + void negate0();
1.26 + void nequal0();
1.27 +};
1.28 +
1.29 +CPPUNIT_TEST_SUITE_REGISTRATION(NeqTest);
1.30 +
1.31 +//
1.32 +// tests implementation
1.33 +//
1.34 +void NeqTest::negate0()
1.35 +{
1.36 + int input [3] = { 1, 2, 3 };
1.37 +
1.38 + int output[3];
1.39 + transform((int*)input, (int*)input + 3, (int*)output, negate<int>());
1.40 +
1.41 + CPPUNIT_ASSERT(output[0]==-1);
1.42 + CPPUNIT_ASSERT(output[1]==-2);
1.43 + CPPUNIT_ASSERT(output[2]==-3);
1.44 +}
1.45 +void NeqTest::nequal0()
1.46 +{
1.47 + int input1 [4] = { 1, 7, 2, 2 };
1.48 + int input2 [4] = { 1, 6, 2, 3 };
1.49 +
1.50 + int output [4];
1.51 + transform((int*)input1, (int*)input1 + 4, (int*)input2, (int*)output, not_equal_to<int>());
1.52 +
1.53 + CPPUNIT_ASSERT(output[0]==0);
1.54 + CPPUNIT_ASSERT(output[1]==1);
1.55 + CPPUNIT_ASSERT(output[2]==0);
1.56 + CPPUNIT_ASSERT(output[3]==1);
1.57 +}