ReactOS  0.4.13-dev-99-g7e18b6d
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)
7 using namespace std;
8 #endif
9 
10 //
11 // TestCase class
12 //
13 class BoundTest : public CPPUNIT_NS::TestCase
14 {
16  CPPUNIT_TEST(lwrbnd1);
17  CPPUNIT_TEST(lwrbnd2);
18  CPPUNIT_TEST(uprbnd1);
19  CPPUNIT_TEST(uprbnd2);
21 
22 protected:
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 }
void uprbnd2()
Definition: bound_test.cpp:50
#define CPPUNIT_TEST_SUITE(X)
Definition: cppunit_mini.h:142
#define CPPUNIT_TEST(X)
Definition: cppunit_mini.h:182
void lwrbnd1()
Definition: bound_test.cpp:59
Definition: features.h:417
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
void lwrbnd2()
Definition: bound_test.cpp:72
const WCHAR * str
_STLP_MOVE_TO_STD_NAMESPACE _ForwardIter lower_bound(_ForwardIter __first, _ForwardIter __last, const _Tp &__val)
Definition: _algo.h:481
#define CPPUNIT_TEST_SUITE_END()
Definition: cppunit_mini.h:191
value_type * iterator
Definition: _vector.h:124
void uprbnd1()
Definition: bound_test.cpp:39
__kernel_size_t size_t
Definition: linux.h:237
static bool char_str_less(const char *a_, const char *b_)
Definition: bound_test.cpp:28
CPPUNIT_TEST_SUITE_REGISTRATION(BoundTest)
_STLP_MOVE_TO_STD_NAMESPACE _ForwardIter upper_bound(_ForwardIter __first, _ForwardIter __last, const _Tp &__val)
Definition: _algo.h:507
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
GLfloat GLfloat v1
Definition: glext.h:6062