diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-03-20 18:35:30 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-03-20 18:35:30 +0300 |
commit | afdaddc4d0745a5bcefad73dd74fd4c03ae3de15 (patch) | |
tree | 83d86453410f1d88ee3ed0116ce90e730c99aa9e /test | |
parent | fb00c75abdfeaa15302a5922859e424b0313d5b5 (diff) | |
download | rspamd-afdaddc4d0745a5bcefad73dd74fd4c03ae3de15.tar.gz rspamd-afdaddc4d0745a5bcefad73dd74fd4c03ae3de15.zip |
* Add fuzzy hashes implementation (with adler-32 roll hash and FNV-32 hash)
* Add test case for fuzzy hashing check
Diffstat (limited to 'test')
-rw-r--r-- | test/rspamd_expression_test.c | 14 | ||||
-rw-r--r-- | test/rspamd_fuzzy_test.c | 44 | ||||
-rw-r--r-- | test/rspamd_test_suite.c | 1 | ||||
-rw-r--r-- | test/tests.h | 3 |
4 files changed, 48 insertions, 14 deletions
diff --git a/test/rspamd_expression_test.c b/test/rspamd_expression_test.c index c81d3d381..7b723e9e6 100644 --- a/test/rspamd_expression_test.c +++ b/test/rspamd_expression_test.c @@ -1,17 +1,3 @@ -#include <sys/types.h> -#include <sys/time.h> -#include <sys/wait.h> -#include <sys/param.h> - -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netdb.h> -#include <syslog.h> -#include <fcntl.h> -#include <stdlib.h> -#include <string.h> -#include <stdio.h> - #include "../src/config.h" #include "../src/main.h" #include "../src/cfg_file.h" diff --git a/test/rspamd_fuzzy_test.c b/test/rspamd_fuzzy_test.c new file mode 100644 index 000000000..d737a9171 --- /dev/null +++ b/test/rspamd_fuzzy_test.c @@ -0,0 +1,44 @@ +#include "../src/config.h" +#include "../src/main.h" +#include "../src/fuzzy.h" +#include "tests.h" + +static char *s1 = "This is sample test text.\r\n" + "abcdefghijklmnopqrstuvwx.\r\n" + "abcdefghijklmnopqrstuvwx.\r\n" + "abcdefghijklmnopqrstuvwx.\r\n" + "abcdefghijklmnopqrstuvwx.\r\n" + "abcdefghijklmnopqrstuvwx.\r\n" + "abcdefghijklmnopqrstuvwx.\r\n" + "abcdefghijklmnopqrstuvwx.\r\n" + "abcdefghijklmnopqrstuvwx.\r\n"; +static char *s2 = "This is sample test text.\r\n" + "abcdefghijklmnopqrstuvwx.\r\n" + "abcdefghijklmnopzrstuvwx.\r\n" + "abcdefghijklmnopqrstuvwx.\r\n" + "abcdefghijklmnopqrstuvwx.\r\n" + "abcdefghijklmnopqrstuvwx.\r\n" + "abcdefghijklmnopqrstuvwx.\r\n" + "abcdefghijklmnopqrstuvwx.\r\n" + "abcdefghijklmnopqrstuvwx.\r\n"; + +void +rspamd_fuzzy_test_func () +{ + memory_pool_t *pool; + fuzzy_hash_t *h1, *h2; + f_str_t f1, f2; + + pool = memory_pool_new (1024); + f1.begin = s1; + f1.len = strlen (s1); + f2.begin = s2; + f2.len = strlen (s2); + + h1 = fuzzy_init (&f1, pool); + h2 = fuzzy_init (&f2, pool); + + msg_info ("rspamd_fuzzy_test_func: difference between strings is %d", fuzzy_compare_hashes (h1, h2)); + + memory_pool_delete (pool); +} diff --git a/test/rspamd_test_suite.c b/test/rspamd_test_suite.c index 81291aa06..b3bc6c893 100644 --- a/test/rspamd_test_suite.c +++ b/test/rspamd_test_suite.c @@ -22,6 +22,7 @@ main (int argc, char **argv) g_test_add_func ("/rspamd/memcached", rspamd_memcached_test_func); g_test_add_func ("/rspamd/mem_pool", rspamd_mem_pool_test_func); + g_test_add_func ("/rspamd/fuzzy", rspamd_fuzzy_test_func); g_test_add_func ("/rspamd/url", rspamd_url_test_func); g_test_add_func ("/rspamd/expression", rspamd_expression_test_func); g_test_add_func ("/rspamd/statfile", rspamd_statfile_test_func); diff --git a/test/tests.h b/test/tests.h index ed852f2d3..c3692d460 100644 --- a/test/tests.h +++ b/test/tests.h @@ -17,6 +17,9 @@ void rspamd_mem_pool_test_func (); /* Expressions */ void rspamd_expression_test_func (); +/* Fuzzy hashes */ +void rspamd_fuzzy_test_func (); + /* Stat file */ void rspamd_statfile_test_func (); |