diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-03-23 14:10:07 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-03-23 14:10:07 +0300 |
commit | c79b5ccd22cbc1c273479f4f88189a18effda533 (patch) | |
tree | 1741743779a70146a61cd1767936aa43d671e36b /test | |
parent | afdaddc4d0745a5bcefad73dd74fd4c03ae3de15 (diff) | |
download | rspamd-c79b5ccd22cbc1c273479f4f88189a18effda533.tar.gz rspamd-c79b5ccd22cbc1c273479f4f88189a18effda533.zip |
* Fix error in expression parser that causes bad errors with expressions that have regexp at the end
* Improve test for fuzzy hashes
* Add new object - TextPart to perl XS library that allows access to stripped parts and fuzzy hashes
* Add documentation for expressions parser and fot Mail::Rspamd::TextPart
* Allways calculate fuzzy hash for text parts
* Store text parts separately from other parts
* Add compare_parts_distance for expressions that calculates difference in 2 parts messages
* Do not try to substitute variables in empty strings
Diffstat (limited to 'test')
-rw-r--r-- | test/rspamd_fuzzy_test.c | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/test/rspamd_fuzzy_test.c b/test/rspamd_fuzzy_test.c index d737a9171..9feeb4500 100644 --- a/test/rspamd_fuzzy_test.c +++ b/test/rspamd_fuzzy_test.c @@ -21,24 +21,56 @@ static char *s2 = "This is sample test text.\r\n" "abcdefghijklmnopqrstuvwx.\r\n" "abcdefghijklmnopqrstuvwx.\r\n" "abcdefghijklmnopqrstuvwx.\r\n"; +static char *s3 = ""; +static char *s4 = "abcdefghijklmn\r\n"; +static char *s5 = "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; + fuzzy_hash_t *h1, *h2, *h3, *h4, *h5; + f_str_t f1, f2, f3, f4, f5; + int diff1, diff2; pool = memory_pool_new (1024); f1.begin = s1; f1.len = strlen (s1); f2.begin = s2; f2.len = strlen (s2); + f3.begin = s3; + f3.len = strlen (s3); + f4.begin = s4; + f4.len = strlen (s4); + f5.begin = s5; + f5.len = strlen (s5); h1 = fuzzy_init (&f1, pool); h2 = fuzzy_init (&f2, pool); + h3 = fuzzy_init (&f3, pool); + h4 = fuzzy_init (&f4, pool); + h5 = fuzzy_init (&f5, pool); - msg_info ("rspamd_fuzzy_test_func: difference between strings is %d", fuzzy_compare_hashes (h1, h2)); + diff1 = fuzzy_compare_hashes (h3, h4) + fuzzy_compare_hashes (h2, h4); + diff2 = fuzzy_compare_hashes (h2, h5); + msg_debug ("rspamd_fuzzy_test_func: s1, s2 difference between strings is %d", fuzzy_compare_hashes (h1, h2)); + msg_debug ("rspamd_fuzzy_test_func: s1, s3 difference between strings is %d", fuzzy_compare_hashes (h1, h3)); + msg_debug ("rspamd_fuzzy_test_func: s3, s4 difference between strings is %d", fuzzy_compare_hashes (h3, h4)); + msg_debug ("rspamd_fuzzy_test_func: s2, s4 difference between strings is %d", fuzzy_compare_hashes (h2, h4)); + msg_debug ("rspamd_fuzzy_test_func: s2, s5 difference between strings is %d", diff2); + + /* Identical strings */ + g_assert (diff2 == 0); + /* Totally different strings */ + g_assert (diff1 == 200); memory_pool_delete (pool); } |