Sha256: e502d6e031d7f380a52f8b2e1fc744704ae4d0ddc8de51e452a8404d2a5cecb3

Contents?: true

Size: 1.6 KB

Versions: 182

Compression:

Stored size: 1.6 KB

Contents

;;; word-count-test.el --- Tests for word-count (exercism)

;;; Commentary:

;;; Code:

(load-file "word-count.el")


(defun equal-assoc (a b)
  (equal (sort a #'(lambda (a b) (not (string< (car a) (car b)))))
         (sort b #'(lambda (a b) (not (string< (car a) (car b)))))))


(ert-deftest no-words-test ()
  (should (equal (word-count "")
                 nil)))


(ert-deftest count-one-word-test ()
  (should (equal (word-count "word")
                 '(("word" . 1)))))


(ert-deftest count-one-of-each-word-test ()
  (should (equal (word-count "one of each")
                 '(("each" . 1) 
                   ("of" . 1)
                   ("one" . 1)))))


(ert-deftest multiple-occurrences-of-a-word-test ()
  (should (equal (word-count "one fish two fish red fish blue fish")
                 '(("blue" . 1) 
                   ("red" . 1) 
                   ("two" . 1) 
                   ("fish" . 4)
                   ("one" . 1)))))


(ert-deftest ignore-punctuation-test ()
  (should (equal (word-count "car : carpet as java : javascript!!&@$%^&")
                 '(("javascript" . 1)
                   ("java" . 1)
                   ("as" . 1)
                   ("carpet" . 1)
                   ("car" . 1)))))


(ert-deftest include-numbers-test ()
  (should (equal (word-count "testing, 1, 2 testing")
                 '(("2" . 1)
                   ("1" . 1)
                   ("testing" . 2)))))


(ert-deftest normalize-case-test ()
  (should (equal (word-count "go Go GO Stop stop")
                 '(("stop" . 2)
                   ("go" . 3)))))


(provide 'word-count)
;;; word-count-test.el ends here

Version data entries

182 entries across 182 versions & 1 rubygems

Version Path
trackler-2.1.0.27 tracks/elisp/exercises/word-count/word-count-test.el
trackler-2.1.0.26 tracks/elisp/exercises/word-count/word-count-test.el
trackler-2.1.0.25 tracks/elisp/exercises/word-count/word-count-test.el
trackler-2.1.0.24 tracks/elisp/exercises/word-count/word-count-test.el
trackler-2.1.0.23 tracks/elisp/exercises/word-count/word-count-test.el
trackler-2.1.0.22 tracks/elisp/exercises/word-count/word-count-test.el
trackler-2.1.0.21 tracks/elisp/exercises/word-count/word-count-test.el
trackler-2.1.0.20 tracks/elisp/exercises/word-count/word-count-test.el
trackler-2.1.0.19 tracks/elisp/exercises/word-count/word-count-test.el
trackler-2.1.0.18 tracks/elisp/exercises/word-count/word-count-test.el
trackler-2.1.0.17 tracks/elisp/exercises/word-count/word-count-test.el
trackler-2.1.0.16 tracks/elisp/exercises/word-count/word-count-test.el
trackler-2.1.0.15 tracks/elisp/exercises/word-count/word-count-test.el
trackler-2.1.0.14 tracks/elisp/exercises/word-count/word-count-test.el
trackler-2.1.0.13 tracks/elisp/exercises/word-count/word-count-test.el
trackler-2.1.0.12 tracks/elisp/exercises/word-count/word-count-test.el
trackler-2.1.0.11 tracks/elisp/exercises/word-count/word-count-test.el
trackler-2.1.0.10 tracks/elisp/exercises/word-count/word-count-test.el
trackler-2.1.0.9 tracks/elisp/exercises/word-count/word-count-test.el
trackler-2.1.0.8 tracks/elisp/exercises/word-count/word-count-test.el