ReactOS  0.4.14-dev-50-g13bb5e2
FindTest Class Reference
Inheritance diagram for FindTest:
Collaboration diagram for FindTest:

Protected Member Functions

void find0 ()
 
void find1 ()
 
void findif0 ()
 
void findif1 ()
 
void find_char ()
 

Static Protected Member Functions

static bool odd (int a_)
 
static bool div_3 (int a_)
 

Private Member Functions

 CPPUNIT_TEST_SUITE (FindTest)
 
 CPPUNIT_TEST (find0)
 
 CPPUNIT_TEST (find1)
 
 CPPUNIT_TEST (findif0)
 
 CPPUNIT_TEST (findif1)
 
 CPPUNIT_TEST (find_char)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 13 of file find_test.cpp.

Member Function Documentation

◆ CPPUNIT_TEST() [1/5]

FindTest::CPPUNIT_TEST ( find0  )
private

◆ CPPUNIT_TEST() [2/5]

FindTest::CPPUNIT_TEST ( find1  )
private

◆ CPPUNIT_TEST() [3/5]

FindTest::CPPUNIT_TEST ( findif0  )
private

◆ CPPUNIT_TEST() [4/5]

FindTest::CPPUNIT_TEST ( findif1  )
private

◆ CPPUNIT_TEST() [5/5]

FindTest::CPPUNIT_TEST ( find_char  )
private

◆ CPPUNIT_TEST_SUITE()

FindTest::CPPUNIT_TEST_SUITE ( FindTest  )
private

◆ CPPUNIT_TEST_SUITE_END()

FindTest::CPPUNIT_TEST_SUITE_END ( )
private

◆ div_3()

bool FindTest::div_3 ( int  a_)
staticprotected

Definition at line 112 of file find_test.cpp.

113 {
114  return a_ % 3 ? 0 : 1;
115 }

◆ find0()

void FindTest::find0 ( )
protected

Definition at line 38 of file find_test.cpp.

39 {
40  int numbers[10] = { 0, 1, 4, 9, 16, 25, 36, 49, 64 };
41 
42  int *location = find((int*)numbers, (int*)numbers + 10, 25);
43 
44  CPPUNIT_ASSERT((location - numbers)==5);
45 
46  int *out_range = find((int*)numbers, (int*)numbers + 10, 128);
47 
48  CPPUNIT_ASSERT( out_range == (int *)(numbers + 10) );
49 }
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
static TAGID TAGID find
Definition: db.cpp:153

◆ find1()

void FindTest::find1 ( )
protected

Definition at line 64 of file find_test.cpp.

65 {
66  int years[] = { 1942, 1952, 1962, 1972, 1982, 1992 };
67 
68  const unsigned yearCount = sizeof(years) / sizeof(years[0]);
69  int* location = find((int*)years, (int*)years + yearCount, 1972);
70 
71  CPPUNIT_ASSERT((location - years)==3);
72 }
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
static TAGID TAGID find
Definition: db.cpp:153

◆ find_char()

void FindTest::find_char ( )
protected

Definition at line 117 of file find_test.cpp.

118 {
119  char str[] = "abcdefghij";
120  char *pstr = (char*)str;
121  const char* cpstr = (const char*)str;
122  size_t str_size = sizeof(str) / sizeof(char);
123 
124  char *d = find(pstr, pstr + str_size, 'd');
125  CPPUNIT_ASSERT( *d == 'd' );
126 
127  const char *e = find(cpstr, cpstr + str_size, 'e');
128  CPPUNIT_ASSERT( *e == 'e' );
129 
130  char *last = find(pstr, pstr + str_size, 'x');
131  CPPUNIT_ASSERT( last == pstr + str_size );
132 
133  const char *clast = find(cpstr, cpstr + str_size, 'x');
134  CPPUNIT_ASSERT( clast == cpstr + str_size );
135 }
POINT last
Definition: font.c:46
#define e
Definition: ke_i.h:82
const WCHAR * str
#define d
Definition: ke_i.h:81
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
static TAGID TAGID find
Definition: db.cpp:153

◆ findif0()

void FindTest::findif0 ( )
protected

Definition at line 74 of file find_test.cpp.

75 {
76  {
77  int numbers[6] = { 2, 4, 8, 15, 32, 64 };
78  int *location = find_if((int*)numbers, (int*)numbers + 6, odd);
79 
80  CPPUNIT_ASSERT((location - numbers)==3);
81 
82  int numbers_even[6] = { 2, 4, 8, 16, 32, 64 };
83 
84  int *out_range = find_if((int*)numbers_even, (int*)numbers_even + 6, odd);
85 
86  CPPUNIT_ASSERT( out_range == (int *)(numbers_even + 6) );
87  }
88 
89  {
90  Key keys[10] = { {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0} };
91  Key const* k = find(keys + 0, keys + 10, 5);
92  CPPUNIT_ASSERT( k == keys + 10 );
93  }
94 }
Definition: unary.h:11
_STLP_MOVE_TO_STD_NAMESPACE _InputIter find_if(_InputIter __first, _InputIter __last, _Predicate __pred)
Definition: _algobase.c:214
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
static TAGID TAGID find
Definition: db.cpp:153
int k
Definition: mpi.c:3369

◆ findif1()

void FindTest::findif1 ( )
protected

Definition at line 96 of file find_test.cpp.

97 {
98  typedef vector <int> IntVec;
99  IntVec v(10);
100  for(int i = 0; (size_t)i < v.size(); ++i)
101  v[i] =(i + 1) *(i + 1);
102  IntVec::iterator iter;
103  iter = find_if(v.begin(), v.end(), div_3);
104  CPPUNIT_ASSERT((iter - v.begin())==2);
105 }
_STLP_MOVE_TO_STD_NAMESPACE _InputIter find_if(_InputIter __first, _InputIter __last, _Predicate __pred)
Definition: _algobase.c:214
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
__kernel_size_t size_t
Definition: linux.h:237
static bool div_3(int a_)
Definition: find_test.cpp:112
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
const GLdouble * v
Definition: gl.h:2040

◆ odd()

bool FindTest::odd ( int  a_)
staticprotected

Definition at line 107 of file find_test.cpp.

108 {
109  return (a_ % 2) != 0;
110 }

The documentation for this class was generated from the following file: