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