ReactOS  0.4.15-dev-5097-g328cc41
HeapTest Class Reference
Inheritance diagram for HeapTest:
Collaboration diagram for HeapTest:

Protected Member Functions

void mkheap0 ()
 
void mkheap1 ()
 
void pheap1 ()
 
void pheap2 ()
 

Private Member Functions

 CPPUNIT_TEST_SUITE (HeapTest)
 
 CPPUNIT_TEST (mkheap0)
 
 CPPUNIT_TEST (mkheap1)
 
 CPPUNIT_TEST (pheap1)
 
 CPPUNIT_TEST (pheap2)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 14 of file heap_test.cpp.

Member Function Documentation

◆ CPPUNIT_TEST() [1/4]

HeapTest::CPPUNIT_TEST ( mkheap0  )
private

◆ CPPUNIT_TEST() [2/4]

HeapTest::CPPUNIT_TEST ( mkheap1  )
private

◆ CPPUNIT_TEST() [3/4]

HeapTest::CPPUNIT_TEST ( pheap1  )
private

◆ CPPUNIT_TEST() [4/4]

HeapTest::CPPUNIT_TEST ( pheap2  )
private

◆ CPPUNIT_TEST_SUITE()

HeapTest::CPPUNIT_TEST_SUITE ( HeapTest  )
private

◆ CPPUNIT_TEST_SUITE_END()

HeapTest::CPPUNIT_TEST_SUITE_END ( )
private

◆ mkheap0()

void HeapTest::mkheap0 ( )
protected

Definition at line 35 of file heap_test.cpp.

36 {
37  int numbers[6] = { 5, 10, 4, 13, 11, 19 };
38 
39  make_heap(numbers, numbers + 6);
40  CPPUNIT_ASSERT(numbers[0]==19)
41  pop_heap(numbers, numbers + 6);
42  CPPUNIT_ASSERT(numbers[0]==13)
43  pop_heap(numbers, numbers + 5);
44  CPPUNIT_ASSERT(numbers[0]==11)
45  pop_heap(numbers, numbers + 4);
46  CPPUNIT_ASSERT(numbers[0]==10)
47  pop_heap(numbers, numbers + 3);
48  CPPUNIT_ASSERT(numbers[0]==5)
49  pop_heap(numbers, numbers + 2);
50  CPPUNIT_ASSERT(numbers[0]==4)
51  pop_heap(numbers, numbers + 1);
52 }
void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
Definition: _heap.c:138
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
Definition: _heap.c:206

◆ mkheap1()

void HeapTest::mkheap1 ( )
protected

Definition at line 53 of file heap_test.cpp.

54 {
55  int numbers[6] = { 5, 10, 4, 13, 11, 19 };
56 
57  make_heap(numbers, numbers + 6, greater<int>());
58 
59  CPPUNIT_ASSERT(numbers[0]==4)
60  pop_heap(numbers, numbers + 6, greater<int>());
61  CPPUNIT_ASSERT(numbers[0]==5)
62  pop_heap(numbers, numbers + 5, greater<int>());
63  CPPUNIT_ASSERT(numbers[0]==10)
64  pop_heap(numbers, numbers + 4, greater<int>());
65  CPPUNIT_ASSERT(numbers[0]==11)
66  pop_heap(numbers, numbers + 3, greater<int>());
67  CPPUNIT_ASSERT(numbers[0]==13)
68  pop_heap(numbers, numbers + 2, greater<int>());
69  CPPUNIT_ASSERT(numbers[0]==19)
70 }
void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
Definition: _heap.c:138
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
Definition: _heap.c:206

◆ pheap1()

void HeapTest::pheap1 ( )
protected

Definition at line 71 of file heap_test.cpp.

72 {
73  vector<int> v;
74 
75  v.push_back(1);
76  v.push_back(20);
77  v.push_back(4);
78  make_heap(v.begin(), v.end());
79 
80  v.push_back(7);
81  push_heap(v.begin(), v.end());
82 
83  sort_heap(v.begin(), v.end());
84 
85  CPPUNIT_ASSERT(v[0]==1);
86  CPPUNIT_ASSERT(v[1]==4);
87  CPPUNIT_ASSERT(v[2]==7);
88  CPPUNIT_ASSERT(v[3]==20);
89 }
_STLP_INLINE_LOOP void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
Definition: _heap.h:99
void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
Definition: _heap.c:65
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
const GLdouble * v
Definition: gl.h:2040
void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
Definition: _heap.c:206

◆ pheap2()

void HeapTest::pheap2 ( )
protected

Definition at line 90 of file heap_test.cpp.

91 {
92  vector<int> v;
93 
94  v.push_back(1);
95  v.push_back(20);
96  v.push_back(4);
97  make_heap(v.begin(), v.end(), greater<int>());
98 
99  v.push_back(7);
100  push_heap(v.begin(), v.end(), greater<int>());
101 
102  sort_heap(v.begin(), v.end(), greater<int>());
103 
104  CPPUNIT_ASSERT(v[0]==20);
105  CPPUNIT_ASSERT(v[1]==7);
106  CPPUNIT_ASSERT(v[2]==4);
107  CPPUNIT_ASSERT(v[3]==1);
108 }
_STLP_INLINE_LOOP void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
Definition: _heap.h:99
void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
Definition: _heap.c:65
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
const GLdouble * v
Definition: gl.h:2040
void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
Definition: _heap.c:206

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