How to map a test onto a list of numbers
Posted
by Arthur Ulfeldt
on Stack Overflow
See other posts from Stack Overflow
or by Arthur Ulfeldt
Published on 2010-05-16T23:25:21Z
Indexed on
2010/05/16
23:30 UTC
Read the original article
Hit count: 235
clojure
|unit-testing
I have a function with a bug:
user> (-> 42 int-to-bytes bytes-to-int)
42
user> (-> 128 int-to-bytes bytes-to-int)
-128
user>
looks like I need to handle overflow when converting back...
Better write a test to make sure this never happens again. This project is using clojure.contrib.test-is so i write:
(deftest int-to-bytes-to-int
(let [lots-of-big-numbers (big-test-numbers)]
(map #(is (= (-> %
int-to-bytes
bytes-to-int)
%))
lots-of-big-numbers)))
This should be testing converting to a seq of bytes and back again produces the origional result on a list of 10000 random numbers. Looks OK in theory? except none of the tests ever run.
Testing com.cryptovide.miscTest
Ran 23 tests containing 34 assertions.
0 failures, 0 errors.
- why don't the tests run?
- what can I do to make them run?
© Stack Overflow or respective owner