Files
csc/test/csc/core_test.clj
2018-12-21 12:30:21 +01:00

28 lines
1009 B
Clojure

(ns csc.core-test
(:require [clojure.test :refer :all]
[csc.core :refer :all]))
(deftest correct-words
(testing "Test that we can check whether correct and incorrect words are marked as such"
(is (correct? "hug"))
(is (not (correct? "heg")))))
(deftest get-distance
(testing "Test that we can get the correct distance from the Java side"
(is (= (distance "abc" "abc") 0))
(is (= (distance "abc" "abd") 1))
(is (= (distance "abc" "boom") 4))))
(deftest get-native-distance
(testing "Test that we can get the correct distance from the Clojure side"
(is (= (native-distance "abc" "abc") 0))
(is (= (native-distance "abc" "abd") 1))
(is (= (native-distance "abc" "boom") 4))))
(deftest get-nearest-word
(testing "Test that we can find the nearest word to any given word"
(is (= "hug" (nearest-word "hug" true)))
(is (= "hug" (nearest-word "hug" false)))
(is (= "hug" (nearest-word "heg" true)))
(is (= "hug" (nearest-word "heg" false)))))