ReactOS  0.4.14-dev-41-g31d7680
bsearch_test.cpp
Go to the documentation of this file.
1 #include <algorithm>
2 
4 
5 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
6 using namespace std;
7 #endif
8 
9 //
10 // TestCase class
11 //
12 class BsearchTest : public CPPUNIT_NS::TestCase
13 {
15  CPPUNIT_TEST(bsearch1);
16  CPPUNIT_TEST(bsearch2);
18 
19 protected:
20  void bsearch1();
21  void bsearch2();
22  static bool str_compare(const char* a_, const char* b_);
23 };
24 
26 
27 //
28 // tests implementation
29 //
31 {
32  int vector[100];
33  for(int i = 0; i < 100; i++)
34  vector[i] = i;
35  CPPUNIT_ASSERT(binary_search(vector, vector + 100, 42));
36 }
37 
39 {
40  char const* labels[] = { "aa", "dd", "ff", "jj", "ss", "zz" };
41  const unsigned count = sizeof(labels) / sizeof(labels[0]);
42  // DEC C++ generates incorrect template instatiation code
43  // for "ff" so must cast
44  CPPUNIT_ASSERT(binary_search(labels, labels + count, (const char *)"ff", str_compare));
45 }
46 bool BsearchTest::str_compare(const char* a_, const char* b_)
47 {
48  return strcmp(a_, b_) < 0 ? 1 : 0;
49 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define CPPUNIT_TEST_SUITE(X)
Definition: cppunit_mini.h:142
#define CPPUNIT_TEST(X)
Definition: cppunit_mini.h:182
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
#define CPPUNIT_TEST_SUITE_END()
Definition: cppunit_mini.h:191
void bsearch2()
static bool str_compare(const char *a_, const char *b_)
void bsearch1()
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
CPPUNIT_TEST_SUITE_REGISTRATION(BsearchTest)
bool binary_search(_ForwardIter __first, _ForwardIter __last, const _Tp &__val)
Definition: _algo.h:553