ReactOS  0.4.15-dev-3303-g1ade494
NthElemTest Class Reference
Inheritance diagram for NthElemTest:
Collaboration diagram for NthElemTest:

Protected Member Functions

void nthelem0 ()
 
void nthelem1 ()
 
void nthelem2 ()
 

Private Member Functions

 CPPUNIT_TEST_SUITE (NthElemTest)
 
 CPPUNIT_TEST (nthelem0)
 
 CPPUNIT_TEST (nthelem1)
 
 CPPUNIT_TEST (nthelem2)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 14 of file nthelm_test.cpp.

Member Function Documentation

◆ CPPUNIT_TEST() [1/3]

NthElemTest::CPPUNIT_TEST ( nthelem0  )
private

◆ CPPUNIT_TEST() [2/3]

NthElemTest::CPPUNIT_TEST ( nthelem1  )
private

◆ CPPUNIT_TEST() [3/3]

NthElemTest::CPPUNIT_TEST ( nthelem2  )
private

◆ CPPUNIT_TEST_SUITE()

NthElemTest::CPPUNIT_TEST_SUITE ( NthElemTest  )
private

◆ CPPUNIT_TEST_SUITE_END()

NthElemTest::CPPUNIT_TEST_SUITE_END ( )
private

◆ nthelem0()

void NthElemTest::nthelem0 ( )
protected

Definition at line 33 of file nthelm_test.cpp.

34 {
35  int numbers[7] = { 5, 2, 4, 1, 0, 3 ,77};
36  nth_element(numbers, numbers + 3, numbers + 6);
37 
38  CPPUNIT_ASSERT(numbers[0]==1);
39  CPPUNIT_ASSERT(numbers[1]==0);
40  CPPUNIT_ASSERT(numbers[2]==2);
41  CPPUNIT_ASSERT(numbers[3]==3);
42  CPPUNIT_ASSERT(numbers[4]==4);
43  CPPUNIT_ASSERT(numbers[5]==5);
44 }
_STLP_MOVE_TO_STD_NAMESPACE void nth_element(_RandomAccessIter __first, _RandomAccessIter __nth, _RandomAccessIter __last)
Definition: _algo.c:1335
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200

◆ nthelem1()

void NthElemTest::nthelem1 ( )
protected

Definition at line 45 of file nthelm_test.cpp.

46 {
47  //6 8 5 1 7 4 1 5 2 6
48  //1 1 4 2 5 5 6 7 8 6
49  int numbers[10] = { 6, 8, 5, 1, 7, 4, 1, 5, 2, 6 };
50 
51  vector <int> v1(numbers, numbers+10);
52  nth_element(v1.begin(), v1.begin() + v1.size() / 2, v1.end());
53 
54  CPPUNIT_ASSERT(v1[0]==1);
55  CPPUNIT_ASSERT(v1[1]==1);
56  CPPUNIT_ASSERT(v1[2]==4);
57  CPPUNIT_ASSERT(v1[3]==2);
58  CPPUNIT_ASSERT(v1[4]==5);
59  CPPUNIT_ASSERT(v1[5]==5);
60  CPPUNIT_ASSERT(v1[6]==6);
61  CPPUNIT_ASSERT(v1[7]==7);
62  CPPUNIT_ASSERT(v1[8]==8);
63  CPPUNIT_ASSERT(v1[9]==6);
64 }
_STLP_MOVE_TO_STD_NAMESPACE void nth_element(_RandomAccessIter __first, _RandomAccessIter __nth, _RandomAccessIter __last)
Definition: _algo.c:1335
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
GLfloat GLfloat v1
Definition: glext.h:6062

◆ nthelem2()

void NthElemTest::nthelem2 ( )
protected

Definition at line 65 of file nthelm_test.cpp.

66 {
67  //4 5 4 2 1 7 4 3 1 6
68  //6 7 4 4 5 4 3 2 1 1
69 
70  int numbers[10] = { 4, 5, 4, 2, 1, 7, 4, 3, 1, 6 };
71  vector <int> v1(numbers, numbers+10);
72  nth_element(v1.begin(), v1.begin() + v1.size() / 2, v1.end(), greater<int>());
73 
74  CPPUNIT_ASSERT(v1[0]==6);
75  CPPUNIT_ASSERT(v1[1]==7);
76  CPPUNIT_ASSERT(v1[2]==4);
77  CPPUNIT_ASSERT(v1[3]==4);
78  CPPUNIT_ASSERT(v1[4]==5);
79  CPPUNIT_ASSERT(v1[5]==4);
80  CPPUNIT_ASSERT(v1[6]==3);
81  CPPUNIT_ASSERT(v1[7]==2);
82  CPPUNIT_ASSERT(v1[8]==1);
83  CPPUNIT_ASSERT(v1[9]==1);
84 }
_STLP_MOVE_TO_STD_NAMESPACE void nth_element(_RandomAccessIter __first, _RandomAccessIter __nth, _RandomAccessIter __last)
Definition: _algo.c:1335
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
GLfloat GLfloat v1
Definition: glext.h:6062

The documentation for this class was generated from the following file: