ReactOS 0.4.15-dev-8021-g7ce96fd
AdjTest Class Reference
Inheritance diagram for AdjTest:
Collaboration diagram for AdjTest:

Protected Member Functions

void adjfind0 ()
 
void adjfind1 ()
 
void adjfind2 ()
 
void adjdiff0 ()
 
void adjdiff1 ()
 
void adjdiff2 ()
 

Static Protected Member Functions

static int equal_length (const char *v1_, const char *v2_)
 
static int mult (int a_, int b_)
 

Private Member Functions

 CPPUNIT_TEST_SUITE (AdjTest)
 
 CPPUNIT_TEST (adjfind0)
 
 CPPUNIT_TEST (adjfind1)
 
 CPPUNIT_TEST (adjfind2)
 
 CPPUNIT_TEST (adjdiff0)
 
 CPPUNIT_TEST (adjdiff1)
 
 CPPUNIT_TEST (adjdiff2)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 14 of file adj_test.cpp.

Member Function Documentation

◆ adjdiff0()

void AdjTest::adjdiff0 ( )
protected

Definition at line 85 of file adj_test.cpp.

86{
87 int numbers[5] = { 1, 2, 4, 8, 16 };
88 int difference[5];
89 adjacent_difference(numbers, numbers + 5, (int*)difference);
90 CPPUNIT_ASSERT(difference[0]==1);
91 CPPUNIT_ASSERT(difference[1]==1);
92 CPPUNIT_ASSERT(difference[2]==2);
93 CPPUNIT_ASSERT(difference[3]==4);
94 CPPUNIT_ASSERT(difference[4]==8);
95}
_STLP_MOVE_TO_STD_NAMESPACE _OutputIterator adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
Definition: _numeric.h:121
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200

◆ adjdiff1()

void AdjTest::adjdiff1 ( )
protected

Definition at line 96 of file adj_test.cpp.

97{
98 vector <int> v(10);
99 for(int i = 0; (size_t)i < v.size(); ++i)
100 v[i] = i * i;
101 vector<int> result(v.size());
102 adjacent_difference(v.begin(), v.end(), result.begin());
109 CPPUNIT_ASSERT(result[6]==11)
110 CPPUNIT_ASSERT(result[7]==13)
111 CPPUNIT_ASSERT(result[8]==15)
112 CPPUNIT_ASSERT(result[9]==17)
113}
__kernel_size_t size_t
Definition: linux.h:237
const GLdouble * v
Definition: gl.h:2040
GLuint64EXT * result
Definition: glext.h:11304
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

◆ adjdiff2()

void AdjTest::adjdiff2 ( )
protected

Definition at line 114 of file adj_test.cpp.

115{
116 vector <int> v(10);
117 for (int i = 0; (size_t)i < v.size(); ++i)
118 v[i] = i + 1;
119 vector <int> result(v.size());
120 adjacent_difference(v.begin(), v.end(), result.begin(), mult);
124 CPPUNIT_ASSERT(result[3]==12)
125 CPPUNIT_ASSERT(result[4]==20)
126 CPPUNIT_ASSERT(result[5]==30)
127 CPPUNIT_ASSERT(result[6]==42)
128 CPPUNIT_ASSERT(result[7]==56)
129 CPPUNIT_ASSERT(result[8]==72)
130 CPPUNIT_ASSERT(result[9]==90)
131}
static int mult(int a_, int b_)
Definition: adj_test.cpp:132

◆ adjfind0()

void AdjTest::adjfind0 ( )
protected

Definition at line 41 of file adj_test.cpp.

42{
43 int numbers1 [5] = { 1, 2, 4, 8, 16 };
44 int numbers2 [5] = { 5, 3, 2, 1, 1 };
45
46 int* location = adjacent_find((int*)numbers1, (int*)numbers1 + 5);
47 CPPUNIT_ASSERT(location == numbers1 + 5); // no adj so loc should be _last
48
49 location = adjacent_find((int*)numbers2, (int*)numbers2 + 5);
50 CPPUNIT_ASSERT(location != numbers2 + 5); // adj location off should be 3 (first 1)
51 CPPUNIT_ASSERT((location - numbers2)==3);
52}
_STLP_INLINE_LOOP _ForwardIter adjacent_find(_ForwardIter __first, _ForwardIter __last, _BinaryPredicate __binary_pred)
Definition: _algo.h:82

◆ adjfind1()

void AdjTest::adjfind1 ( )
protected

Definition at line 53 of file adj_test.cpp.

54{
55 typedef vector<int> IntVector;
56 IntVector v(10);
57 for (int i = 0; (size_t)i < v.size(); ++i)
58 v[i] = i;
59 IntVector::iterator location;
60 location = adjacent_find(v.begin(), v.end());
61 CPPUNIT_ASSERT(location == v.end());
62 v[6] = 7;
63 location = adjacent_find(v.begin(), v.end());
64 CPPUNIT_ASSERT(location != v.end());
65}

◆ adjfind2()

void AdjTest::adjfind2 ( )
protected

Definition at line 66 of file adj_test.cpp.

67{
68 typedef vector <const char*> CStrVector;
69
70 const char* names[] = { "Brett", "Graham", "Jack", "Mike", "Todd" };
71
72 const int nameCount = sizeof(names)/sizeof(names[0]);
73 CStrVector v(nameCount);
74 for(int i = 0; i < nameCount; i++)
75 v[i] = names[i];
76 CStrVector::iterator location;
77 location = adjacent_find(v.begin(), v.end(), equal_length);
78
79 CPPUNIT_ASSERT(location != v.end());
80}
static int equal_length(const char *v1_, const char *v2_)
Definition: adj_test.cpp:81
GLuint GLuint * names
Definition: glext.h:11545

◆ CPPUNIT_TEST() [1/6]

AdjTest::CPPUNIT_TEST ( adjdiff0  )
private

◆ CPPUNIT_TEST() [2/6]

AdjTest::CPPUNIT_TEST ( adjdiff1  )
private

◆ CPPUNIT_TEST() [3/6]

AdjTest::CPPUNIT_TEST ( adjdiff2  )
private

◆ CPPUNIT_TEST() [4/6]

AdjTest::CPPUNIT_TEST ( adjfind0  )
private

◆ CPPUNIT_TEST() [5/6]

AdjTest::CPPUNIT_TEST ( adjfind1  )
private

◆ CPPUNIT_TEST() [6/6]

AdjTest::CPPUNIT_TEST ( adjfind2  )
private

◆ CPPUNIT_TEST_SUITE()

AdjTest::CPPUNIT_TEST_SUITE ( AdjTest  )
private

◆ CPPUNIT_TEST_SUITE_END()

AdjTest::CPPUNIT_TEST_SUITE_END ( )
private

◆ equal_length()

int AdjTest::equal_length ( const char v1_,
const char v2_ 
)
staticprotected

Definition at line 81 of file adj_test.cpp.

82{
83 return ::strlen(v1_) == ::strlen(v2_);
84}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269

Referenced by adjfind2().

◆ mult()

int AdjTest::mult ( int  a_,
int  b_ 
)
staticprotected

Definition at line 132 of file adj_test.cpp.

133{
134 return a_ * b_;
135}

Referenced by adjdiff2().


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