5
#include <mimetic/tree.h>
12
struct TEST_CLASS( tree )
14
typedef TreeNode<char> Node;
15
void TEST_FUNCTION( buildTree )
17
const char* words[] = {
18
"pro", "pra", "tre", 0
21
// creates a tree of reversed wordlist (*words)
22
for(int i = 0; words[i]; ++i)
24
Node::NodeList *pChilds = &m_tree.childList();
25
Node::NodeList::iterator it = pChilds->begin();
26
const char *w = words[i];
30
it = find_if(pChilds->begin(), pChilds->end(),
31
FindNodePred<char>(*w));
32
if( it == pChilds->end() )
34
it = pChilds->insert(pChilds->end(),*w);
35
TEST_ASSERT(pChilds->size() > 0);
37
pChilds = &it->childList();
42
void TEST_FUNCTION( search )
44
// boyer-moore algorithm modified to work with
45
// multiple patterns(i.e. boundaries)
57
skip[muster[i]]=mlen-1-i;
59
for(i=j=mlen-1; j>=0; --i, --j)
60
while(text[i] != muster[j])
62
i += max(mlen-j,skip[text[i]]);