less_test.cpp revision e46c9386c4f79aa40185f79a19fc5b2a7ef528b3
1#include <vector>
2#include <algorithm>
3#include <functional>
4
5#include "cppunit/cppunit_proxy.h"
6
7#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
8using namespace std;
9#endif
10
11//
12// TestCase class
13//
14class LessTest : public CPPUNIT_NS::TestCase
15{
16  CPPUNIT_TEST_SUITE(LessTest);
17  CPPUNIT_TEST(lesst);
18  CPPUNIT_TEST(lesseqt);
19  CPPUNIT_TEST_SUITE_END();
20
21protected:
22  void lesst();
23  void lesseqt();
24};
25
26CPPUNIT_TEST_SUITE_REGISTRATION(LessTest);
27
28//
29// tests implementation
30//
31void LessTest::lesst()
32{
33  int array [4] = { 3, 1, 4, 2 };
34  sort(array, array + 4, less<int>());
35
36  CPPUNIT_ASSERT(array[0]==1);
37  CPPUNIT_ASSERT(array[1]==2);
38  CPPUNIT_ASSERT(array[2]==3);
39  CPPUNIT_ASSERT(array[3]==4);
40}
41void LessTest::lesseqt()
42{
43  int array [4] = { 3, 1, 4, 2 };
44  sort(array, array + 4, less_equal<int>());
45
46  CPPUNIT_ASSERT(array[0]==1);
47  CPPUNIT_ASSERT(array[1]==2);
48  CPPUNIT_ASSERT(array[2]==3);
49  CPPUNIT_ASSERT(array[3]==4);
50}
51