ReactOS 0.4.15-dev-8131-g4988de4
bsearch_test.cpp
Go to the documentation of this file.
1#include <algorithm>
2
4
5#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
6using namespace std;
7#endif
8
9//
10// TestCase class
11//
12class BsearchTest : public CPPUNIT_NS::TestCase
13{
18
19protected:
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}
46bool BsearchTest::str_compare(const char* a_, const char* b_)
47{
48 return strcmp(a_, b_) < 0 ? 1 : 0;
49}
bool binary_search(_ForwardIter __first, _ForwardIter __last, const _Tp &__val)
Definition: _algo.h:553
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
static bool str_compare(const char *a_, const char *b_)
CPPUNIT_TEST_SUITE_END()
CPPUNIT_TEST_SUITE(BsearchTest)
CPPUNIT_TEST(bsearch1)
void bsearch2()
void bsearch1()
CPPUNIT_TEST(bsearch2)
#define CPPUNIT_TEST_SUITE_REGISTRATION(X)
Definition: cppunit_mini.h:193
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
GLuint GLuint GLsizei count
Definition: gl.h:1545
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