summaryrefslogtreecommitdiffstats
path: root/test/rspamd_fuzzy_test.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-03-20 18:35:30 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-03-20 18:35:30 +0300
commitafdaddc4d0745a5bcefad73dd74fd4c03ae3de15 (patch)
tree83d86453410f1d88ee3ed0116ce90e730c99aa9e /test/rspamd_fuzzy_test.c
parentfb00c75abdfeaa15302a5922859e424b0313d5b5 (diff)
downloadrspamd-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/rspamd_fuzzy_test.c')
-rw-r--r--test/rspamd_fuzzy_test.c44
1 files changed, 44 insertions, 0 deletions
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);
+}