31
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include <algorithm>
|
|
18 |
#include <functional>
|
|
19 |
|
|
20 |
#include "cppunit/cppunit_proxy.h"
|
|
21 |
|
|
22 |
#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
|
|
23 |
using namespace std;
|
|
24 |
#endif
|
|
25 |
|
|
26 |
//
|
|
27 |
// TestCase class
|
|
28 |
//
|
|
29 |
class ModulusTest : public CPPUNIT_NS::TestCase
|
|
30 |
{
|
|
31 |
CPPUNIT_TEST_SUITE(ModulusTest);
|
|
32 |
CPPUNIT_TEST(modulus0);
|
|
33 |
CPPUNIT_TEST_SUITE_END();
|
|
34 |
|
|
35 |
protected:
|
|
36 |
void modulus0();
|
|
37 |
};
|
|
38 |
|
|
39 |
CPPUNIT_TEST_SUITE_REGISTRATION(ModulusTest);
|
|
40 |
|
|
41 |
//
|
|
42 |
// tests implementation
|
|
43 |
//
|
|
44 |
void ModulusTest::modulus0()
|
|
45 |
{
|
|
46 |
int input1 [4] = { 6, 8, 10, 2 };
|
|
47 |
int input2 [4] = { 4, 2, 11, 3 };
|
|
48 |
|
|
49 |
int output [4];
|
|
50 |
|
|
51 |
transform((int*)input1, (int*)input1 + 4, (int*)input2, (int*)output, modulus<int>());
|
|
52 |
CPPUNIT_ASSERT(output[0]==2);
|
|
53 |
CPPUNIT_ASSERT(output[1]==0);
|
|
54 |
CPPUNIT_ASSERT(output[2]==10);
|
|
55 |
CPPUNIT_ASSERT(output[3]==2);
|
|
56 |
}
|