sl@0
|
1 |
#include <algorithm>
|
sl@0
|
2 |
#include <functional>
|
sl@0
|
3 |
|
sl@0
|
4 |
#include "cppunit/cppunit_proxy.h"
|
sl@0
|
5 |
|
sl@0
|
6 |
#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
|
sl@0
|
7 |
using namespace std;
|
sl@0
|
8 |
#endif
|
sl@0
|
9 |
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// TestCase class
|
sl@0
|
12 |
//
|
sl@0
|
13 |
class ModulusTest : public CPPUNIT_NS::TestCase
|
sl@0
|
14 |
{
|
sl@0
|
15 |
CPPUNIT_TEST_SUITE(ModulusTest);
|
sl@0
|
16 |
CPPUNIT_TEST(modulus0);
|
sl@0
|
17 |
CPPUNIT_TEST_SUITE_END();
|
sl@0
|
18 |
|
sl@0
|
19 |
protected:
|
sl@0
|
20 |
void modulus0();
|
sl@0
|
21 |
};
|
sl@0
|
22 |
|
sl@0
|
23 |
CPPUNIT_TEST_SUITE_REGISTRATION(ModulusTest);
|
sl@0
|
24 |
|
sl@0
|
25 |
//
|
sl@0
|
26 |
// tests implementation
|
sl@0
|
27 |
//
|
sl@0
|
28 |
void ModulusTest::modulus0()
|
sl@0
|
29 |
{
|
sl@0
|
30 |
int input1 [4] = { 6, 8, 10, 2 };
|
sl@0
|
31 |
int input2 [4] = { 4, 2, 11, 3 };
|
sl@0
|
32 |
|
sl@0
|
33 |
int output [4];
|
sl@0
|
34 |
|
sl@0
|
35 |
transform((int*)input1, (int*)input1 + 4, (int*)input2, (int*)output, modulus<int>());
|
sl@0
|
36 |
CPPUNIT_ASSERT(output[0]==2);
|
sl@0
|
37 |
CPPUNIT_ASSERT(output[1]==0);
|
sl@0
|
38 |
CPPUNIT_ASSERT(output[2]==10);
|
sl@0
|
39 |
CPPUNIT_ASSERT(output[3]==2);
|
sl@0
|
40 |
}
|