ReactOS 0.4.15-dev-7961-gdcf9eb0
bound_test.cpp
Go to the documentation of this file.
1#include <vector>
2#include <algorithm>
3
5
6#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
7using namespace std;
8#endif
9
10//
11// TestCase class
12//
13class BoundTest : public CPPUNIT_NS::TestCase
14{
21
22protected:
23 void lwrbnd1();
24 void lwrbnd2();
25 void uprbnd1();
26 void uprbnd2();
27
28 static bool char_str_less(const char* a_, const char* b_)
29 {
30 return strcmp(a_, b_) < 0 ? 1 : 0;
31 }
32};
33
35
36//
37// tests implementation
38//
40{
41 int arr[20];
42 for(int i = 0; i < 20; i++)
43 {
44 arr[i] = i/4;
45 }
46 int location = upper_bound((int*)arr, (int*)arr + 20, 3) - arr;
48}
49
51{
52 char const* str [] = { "a", "a", "b", "b", "q", "w", "z" };
53
54 const unsigned strCt = sizeof(str)/sizeof(str[0]);
55
56 int location = (upper_bound((char const**)str, (char const**)str + strCt, (const char *)"d", char_str_less) - str);
58}
60{
61 vector <int> v1(20);
62 for (int i = 0; (size_t)i < v1.size(); ++i)
63 {
64 v1[i] = i/4;
65 }
66 // 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4
67 vector<int>::iterator location = lower_bound(v1.begin(), v1.end(), 3);
68
69 CPPUNIT_ASSERT((location - v1.begin())==12);
70}
71
73{
74 char const* str [] = { "a", "a", "b", "b", "q", "w", "z" };
75
76 const unsigned strCt = sizeof(str)/sizeof(str[0]);
77 char const** location = lower_bound((char const**)str, (char const**)str + strCt, (const char *)"d", char_str_less);
78
79 CPPUNIT_ASSERT((location - str) == 4);
80}
_STLP_MOVE_TO_STD_NAMESPACE _ForwardIter upper_bound(_ForwardIter __first, _ForwardIter __last, const _Tp &__val)
Definition: _algo.h:507
_STLP_MOVE_TO_STD_NAMESPACE _ForwardIter lower_bound(_ForwardIter __first, _ForwardIter __last, const _Tp &__val)
Definition: _algo.h:481
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
static bool char_str_less(const char *a_, const char *b_)
Definition: bound_test.cpp:28
void uprbnd1()
Definition: bound_test.cpp:39
CPPUNIT_TEST(uprbnd1)
void lwrbnd2()
Definition: bound_test.cpp:72
CPPUNIT_TEST(lwrbnd2)
CPPUNIT_TEST(uprbnd2)
void uprbnd2()
Definition: bound_test.cpp:50
CPPUNIT_TEST_SUITE_END()
void lwrbnd1()
Definition: bound_test.cpp:59
CPPUNIT_TEST_SUITE(BoundTest)
CPPUNIT_TEST(lwrbnd1)
#define CPPUNIT_TEST_SUITE_REGISTRATION(X)
Definition: cppunit_mini.h:193
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
__kernel_size_t size_t
Definition: linux.h:237
GLfloat GLfloat v1
Definition: glext.h:6062
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
Definition: features.h:417
const WCHAR * str
value_type * iterator
Definition: _vector.h:124