how to

how to test your own algorithms

It is possible to add your own string matching algorithms to smart and testing them against the other algorithms.
A new algorithm must be implemented in C language. The file must contains the following include command

#include "include/main.h"

while the main method must be defined as

int search(unsigned char *x, int m, unsigned char *y, int n)

where x is the pattern, y is the text, and m and n are their length. The method must return the number of occurrences of the pattern in the text.
If the algorithm does not run under particular conditions (for instance when the length of the pattern is less than a given value), please make it return the value -1.
Before compiling the C file, copy the header file main.h (which is in source/algos/include) in the same directory. Then put the compiled binary file in the directory source/bin
Before running a new experimental setting you can test the correctness of your algorithm by executing the following command

$ ./test algoname

where algoname is the name of the binary file of your algorithm. If your algorithm is correct the following output will be dispalyed

Please, wait a moment....
Well done! Test passed successfully

Now you can include your algorithm in smart by using the select. The following command add the algorithm

$ ./select -add algoname

Notice that smart includes the algorithm in the set only if it's correct. If your algorithm is correct the following output will be displayed

Adding the algorithm algoname to SMART
Testing the algorithm for correctness....ok
Algorithm algoname added succesfully.

Now you need to select the algorithm by running the command

$ ./select algoname