Sha256: 124025e9883f34ad1ebfcfb4d4acd2338090ffd96845902c193c8b1275642e3b

Contents?: true

Size: 1.46 KB

Versions: 343

Compression:

Stored size: 1.46 KB

Contents

(ql:quickload "lisp-unit")
#-xlisp-test (load "word-count")

(defpackage #:word-count-test
  (:use #:common-lisp #:lisp-unit))

(in-package #:word-count-test)

(defun assert-assoc-equal (expected actual)
  "The association lists must have the same length and the keys and
  values of the items must match. But the order is not
  important. Equality is tested with equal"
  (assert-equal
      (sort (copy-seq expected) #'string< :key #'car)
      (sort (copy-seq actual) #'string< :key #'car)))

(define-test count-one-word
  (assert-assoc-equal '(("word" . 1))
      (phrase:word-count "word")))

(define-test count-one-of-each
  (assert-assoc-equal '(("one" . 1) ("of" . 1) ("each" . 1))
      (phrase:word-count "one of each")))

(define-test count-multiple-occurrences
  (assert-assoc-equal
   '(("one" . 1) ("fish" . 4) ("two". 1) ("red" . 1) ("blue" . 1))
   (phrase:word-count "one fish two fish red fish blue fish")))

(define-test ignore-punctuation
  (assert-assoc-equal
   '(("car" . 1) ("carpet" . 1) ("as" . 1) ("java" . 1) ("javascript" . 1))
   (phrase:word-count "car : carpet as java : javascript!!&@$%^&")))

(define-test include-numbers
  (assert-assoc-equal '(("testing" . 2) ("1" . 1) ("2" . 1))
      (phrase:word-count "testing, 1, 2 testing")))

(define-test normalize-case
  (assert-assoc-equal '(("go" . 3) ("on" . 3))
	  (phrase:word-count "go ON Go On GO on")))

#-xlisp-test
(let ((*print-errors* t)
      (*print-failures* t))
  (run-tests :all :word-count-test))

Version data entries

343 entries across 343 versions & 1 rubygems

Version Path
trackler-2.2.1.119 tracks/common-lisp/exercises/word-count/word-count-test.lisp
trackler-2.2.1.118 tracks/common-lisp/exercises/word-count/word-count-test.lisp
trackler-2.2.1.117 tracks/common-lisp/exercises/word-count/word-count-test.lisp
trackler-2.2.1.116 tracks/common-lisp/exercises/word-count/word-count-test.lisp
trackler-2.2.1.115 tracks/common-lisp/exercises/word-count/word-count-test.lisp
trackler-2.2.1.114 tracks/common-lisp/exercises/word-count/word-count-test.lisp
trackler-2.2.1.113 tracks/common-lisp/exercises/word-count/word-count-test.lisp
trackler-2.2.1.111 tracks/common-lisp/exercises/word-count/word-count-test.lisp
trackler-2.2.1.110 tracks/common-lisp/exercises/word-count/word-count-test.lisp
trackler-2.2.1.109 tracks/common-lisp/exercises/word-count/word-count-test.lisp
trackler-2.2.1.108 tracks/common-lisp/exercises/word-count/word-count-test.lisp
trackler-2.2.1.107 tracks/common-lisp/exercises/word-count/word-count-test.lisp
trackler-2.2.1.106 tracks/common-lisp/exercises/word-count/word-count-test.lisp
trackler-2.2.1.105 tracks/common-lisp/exercises/word-count/word-count-test.lisp
trackler-2.2.1.104 tracks/common-lisp/exercises/word-count/word-count-test.lisp
trackler-2.2.1.103 tracks/common-lisp/exercises/word-count/word-count-test.lisp
trackler-2.2.1.102 tracks/common-lisp/exercises/word-count/word-count-test.lisp
trackler-2.2.1.101 tracks/common-lisp/exercises/word-count/word-count-test.lisp
trackler-2.2.1.100 tracks/common-lisp/exercises/word-count/word-count-test.lisp
trackler-2.2.1.99 tracks/common-lisp/exercises/word-count/word-count-test.lisp