ReactOS 0.4.16-dev-240-gdb5fa3b
SearchTest Class Reference
Inheritance diagram for SearchTest:
Collaboration diagram for SearchTest:

Protected Member Functions

void search0 ()
 
void search1 ()
 
void search2 ()
 

Static Protected Member Functions

static bool str_equal (const char *a_, const char *b_)
 

Private Member Functions

 CPPUNIT_TEST_SUITE (SearchTest)
 
 CPPUNIT_TEST (search0)
 
 CPPUNIT_TEST (search1)
 
 CPPUNIT_TEST (search2)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 15 of file search_test.cpp.

Member Function Documentation

◆ CPPUNIT_TEST() [1/3]

SearchTest::CPPUNIT_TEST ( search0  )
private

◆ CPPUNIT_TEST() [2/3]

SearchTest::CPPUNIT_TEST ( search1  )
private

◆ CPPUNIT_TEST() [3/3]

SearchTest::CPPUNIT_TEST ( search2  )
private

◆ CPPUNIT_TEST_SUITE()

SearchTest::CPPUNIT_TEST_SUITE ( SearchTest  )
private

◆ CPPUNIT_TEST_SUITE_END()

SearchTest::CPPUNIT_TEST_SUITE_END ( )
private

◆ search0()

void SearchTest::search0 ( )
protected

Definition at line 39 of file search_test.cpp.

40{
41 int v1[6] = { 1, 1, 2, 3, 5, 8 };
42 int v2[6] = { 0, 1, 2, 3, 4, 5 };
43 int v3[2] = { 3, 4 };
44
45 int* location;
46 location = search((int*)v1, (int*)v1 + 6, (int*)v3, (int*)v3 + 2);
48
49 location = search((int*)v2, (int*)v2 + 6, (int*)v3, (int*)v3 + 2);
52}
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
GLfloat GLfloat GLfloat GLfloat v3
Definition: glext.h:6064
GLfloat GLfloat v1
Definition: glext.h:6062
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
static short search(int val, const short *table, int size)
Definition: msg711.c:255

◆ search1()

void SearchTest::search1 ( )
protected

Definition at line 53 of file search_test.cpp.

54{
55 typedef vector <int> IntVec;
56 IntVec v1(10);
57 __iota(v1.begin(), v1.end(), 0);
58 IntVec v2(3);
59 __iota(v2.begin(), v2.end(), 50);
60
61 IntVec::iterator location;
62 location = search(v1.begin(), v1.end(), v2.begin(), v2.end());
63
64 CPPUNIT_ASSERT(location == v1.end());
65
66 __iota(v2.begin(), v2.end(), 4);
67
68 location = search(v1.begin(), v1.end(), v2.begin(), v2.end());
69
70 CPPUNIT_ASSERT(location != v1.end());
71 CPPUNIT_ASSERT(location - v1.begin() == 4);
72}
void __iota(_It __first, _It __last, _Tp __val)
Definition: iota.h:8

◆ search2()

void SearchTest::search2 ( )
protected

Definition at line 73 of file search_test.cpp.

74{
75 char const* grades[] = { "A", "B", "C", "D", "F" };
76 char const* letters[] = { "Q", "E", "D" };
77 const unsigned gradeCount = sizeof(grades) / sizeof(grades[0]);
78 const unsigned letterCount = sizeof(letters) / sizeof(letters[0]);
79 char const** location = search((char const**)grades, (char const**)grades + gradeCount, (char const**)letters, (char const**)letters + letterCount, str_equal);
80
81 CPPUNIT_ASSERT(location == grades + gradeCount);
82
83 copy((char const**)grades + 1, (char const**)grades + 1 + letterCount, (char const**)letters);
84 location = search((char const**)grades, (char const**)grades + gradeCount, (char const**)letters, (char const**)letters + letterCount, str_equal);
85
86 CPPUNIT_ASSERT(location != grades + gradeCount);
87 CPPUNIT_ASSERT(location - grades == 1);
88
89}
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
static bool str_equal(const char *a_, const char *b_)
Definition: search_test.cpp:28

◆ str_equal()

static bool SearchTest::str_equal ( const char a_,
const char b_ 
)
inlinestaticprotected

Definition at line 28 of file search_test.cpp.

29 {
30 return strcmp(a_, b_) == 0 ? 1 : 0;
31 }
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by search2().


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