This repository has been archived by the owner on Jun 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.lisp
33 lines (27 loc) · 1.5 KB
/
test.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
;; Copying and distribution of this file, with or without
;; modification, are permitted in any medium without royalty provided
;; this notice is preserved. This file is offered as-is, without any
;; warranty.
(in-package #:vas-string-metrics)
(defun run-tests ()
"Run vas-string-metrics unit tests. Signals assertion failure on
failed test. Returns nil if all tests pass."
(assert (= 17/18 (jaro-distance "martha" "marhta")))
(assert (< 0.961 (jaro-winkler-distance "martha" "marhta") 0.962))
(assert (= 37/45 (jaro-distance "dwayne" "duane")))
(assert (< 0.84 (jaro-winkler-distance "dwayne" "duane") 0.845))
(assert (= 23/30 (jaro-distance "dixon" "dicksonx")))
(assert (< 0.81 (jaro-winkler-distance "dixon" "dicksonx") 0.82))
(assert (= 0 (jaro-distance "abc" "xyz")))
(assert (= 1 (jaro-distance "foobar" "foobar")))
(assert (= 0 (jaro-winkler-distance "abc" "xyz")))
(assert (= 1 (jaro-winkler-distance "foobar" "foobar")))
(assert (= 3 (levenshtein-distance "sitting" "kitten")))
(assert (= 3 (levenshtein-distance "Sunday" "Saturday")))
(assert (= 2 (levenshtein-distance "gambol" "gumbo")))
(assert (= 0 (normalized-levenshtein-distance "abc" "xyz")))
(assert (= 1 (normalized-levenshtein-distance "foobar" "foobar")))
(assert (= 0.8 (soerensen-dice-coefficient "french republic" "republic of france")))
(assert (< 0.666 (soerensen-dice-coefficient "french republic" "republic of congo") 0.667))
(assert (= 0.25 (soerensen-dice-coefficient "night" "nacht"))))
(export 'run-tests)