ReactOS 0.4.16-dev-329-g9223134
multiset_test.cpp
Go to the documentation of this file.
1#include <set>
2#include <functional>
3
5
6#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
7using namespace std;
8#endif
9
10//
11// TestCase class
12//
13class MultisetTest : public CPPUNIT_NS::TestCase
14{
16
22
23protected:
24 void mset1();
25 void mset3();
26 void mset5();
27
28 static bool less_than(int a_, int b_)
29 {
30 return a_ < b_;
31 }
32
33 static bool greater_than(int a_, int b_)
34 {
35 return a_ > b_;
36 }
37};
38
40
41//
42// tests implementation
43//
45{
46 mset s;
47 CPPUNIT_ASSERT(s.count(42) == 0);
48 s.insert(42);
49 CPPUNIT_ASSERT(s.count(42) == 1);
50 s.insert(42);
51 CPPUNIT_ASSERT(s.count(42) == 2);
52
53 mset::iterator i = s.find(40);
54 CPPUNIT_ASSERT(i == s.end());
55
56 i = s.find(42);
57 CPPUNIT_ASSERT(i != s.end());
58 size_t count = s.erase(42);
60}
62{
63 int array [] = { 3, 6, 1, 2, 3, 2, 6, 7, 9 };
64
65 //Check iterator on a mutable set
66 mset s(array, array + 9);
68 i = s.lower_bound(3);
69 CPPUNIT_ASSERT(*i == 3);
70 i = s.upper_bound(3);
71 CPPUNIT_ASSERT(*i == 6);
73 CPPUNIT_ASSERT(*(p.first) == 6);
74 CPPUNIT_ASSERT(*(p.second) == 6);
75
76 //Check const_iterator on a mutable multiset
78 ci = s.lower_bound(3);
79 CPPUNIT_ASSERT(*ci == 3);
80 ci = s.upper_bound(3);
81 CPPUNIT_ASSERT(*ci == 6);
83#ifdef _STLP_MEMBER_TEMPLATES
84 cp = s.equal_range(5);
85 CPPUNIT_ASSERT(*(cp.first) == 6);
86 CPPUNIT_ASSERT(*(cp.second) == 6);
87#endif
88
89 //Check const_iterator on a const multiset
90 mset const& crs = s;
91 ci = crs.lower_bound(3);
92 CPPUNIT_ASSERT(*ci == 3);
93 ci = crs.upper_bound(3);
94 CPPUNIT_ASSERT(*ci == 6);
95 cp = crs.equal_range(5);
96 CPPUNIT_ASSERT(*(cp.first) == 6);
97 CPPUNIT_ASSERT(*(cp.second) == 6);
98}
100{
101 int array [] = { 3, 6, 1, 9 };
102 int j;
103
106
107 fn_type f(less_than);
108 fn_mset s1(array+0, array + 4 , f );
109 fn_mset::const_iterator i = s1.begin();
110 for (j = 0; i != s1.end(); ++i, ++j) {
111 CPPUNIT_ASSERT(j != 0 || *i == 1);
112 CPPUNIT_ASSERT(j != 1 || *i == 3);
113 CPPUNIT_ASSERT(j != 2 || *i == 6);
114 CPPUNIT_ASSERT(j != 3 || *i == 9);
115 }
116
117 fn_type g(greater_than);
118 fn_mset s2(array, array + 4, g);
119 i = s2.begin();
120 for (j = 0; i != s2.end(); ++i, ++j) {
121 CPPUNIT_ASSERT(j != 0 || *i == 9);
122 CPPUNIT_ASSERT(j != 1 || *i == 6);
123 CPPUNIT_ASSERT(j != 2 || *i == 3);
124 CPPUNIT_ASSERT(j != 3 || *i == 1);
125 }
126
127}
multiset< int, less< int > > mset
static bool less_than(int a_, int b_)
CPPUNIT_TEST(mset1)
CPPUNIT_TEST(mset3)
CPPUNIT_TEST_SUITE_END()
static bool greater_than(int a_, int b_)
CPPUNIT_TEST_SUITE(MultisetTest)
CPPUNIT_TEST(mset5)
Definition: _set.h:220
_Rep_type::iterator iterator
Definition: _set.h:244
_Rep_type::const_iterator const_iterator
Definition: _set.h:245
#define CPPUNIT_TEST_SUITE_REGISTRATION(X)
Definition: cppunit_mini.h:193
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
GLdouble s
Definition: gl.h:2039
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLfloat f
Definition: glext.h:7540
GLboolean GLboolean g
Definition: glext.h:6204
GLfloat GLfloat p
Definition: glext.h:8902
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define f
Definition: ke_i.h:83
POINT cp
Definition: magnifier.c:59
static const WCHAR crs[]
struct S1 s1
struct S2 s2
Definition: features.h:417
Definition: _pair.h:47