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 GreaterTest : public CPPUNIT_NS::TestCase
|
sl@0
|
15 |
{
|
sl@0
|
16 |
CPPUNIT_TEST_SUITE(GreaterTest);
|
sl@0
|
17 |
CPPUNIT_TEST(greatert);
|
sl@0
|
18 |
CPPUNIT_TEST(greatereq);
|
sl@0
|
19 |
CPPUNIT_TEST_SUITE_END();
|
sl@0
|
20 |
|
sl@0
|
21 |
protected:
|
sl@0
|
22 |
void greatert();
|
sl@0
|
23 |
void greatereq();
|
sl@0
|
24 |
};
|
sl@0
|
25 |
|
sl@0
|
26 |
CPPUNIT_TEST_SUITE_REGISTRATION(GreaterTest);
|
sl@0
|
27 |
|
sl@0
|
28 |
//
|
sl@0
|
29 |
// tests implementation
|
sl@0
|
30 |
//
|
sl@0
|
31 |
void GreaterTest::greatert()
|
sl@0
|
32 |
{
|
sl@0
|
33 |
int array[4] = { 3, 1, 4, 2 };
|
sl@0
|
34 |
sort(array, array + 4, greater<int>() );
|
sl@0
|
35 |
|
sl@0
|
36 |
CPPUNIT_ASSERT(array[0]==4);
|
sl@0
|
37 |
CPPUNIT_ASSERT(array[1]==3);
|
sl@0
|
38 |
CPPUNIT_ASSERT(array[2]==2);
|
sl@0
|
39 |
CPPUNIT_ASSERT(array[3]==1);
|
sl@0
|
40 |
}
|
sl@0
|
41 |
void GreaterTest::greatereq()
|
sl@0
|
42 |
{
|
sl@0
|
43 |
int array [4] = { 3, 1, 4, 2 };
|
sl@0
|
44 |
sort(array, array + 4, greater_equal<int>());
|
sl@0
|
45 |
CPPUNIT_ASSERT(array[0]==4);
|
sl@0
|
46 |
CPPUNIT_ASSERT(array[1]==3);
|
sl@0
|
47 |
CPPUNIT_ASSERT(array[2]==2);
|
sl@0
|
48 |
CPPUNIT_ASSERT(array[3]==1);
|
sl@0
|
49 |
}
|