How to match a test to a list of numbers

I have a function with an error:

user> (-> 42 int-to-bytes bytes-to-int) 42 user> (-> 128 int-to-bytes bytes-to-int) -128 user> 

it looks like I need to handle overflow on the inverse transform ...

Better write a test to make sure it never happens again. This project uses clojure.contrib.test - this is how 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 the conversion to seq from bytes and vice versa, which gives the original result in a list of 10,000 random numbers. In order? except that none of the tests have ever been run.

 Testing com.cryptovide.miscTest Ran 23 tests containing 34 assertions. 0 failures, 0 errors. 
  • Why are tests not running?
  • what can i do to run them?
+4
source share
3 answers

dorun + map => doseq

 (doseq [x (big-test-numbers)] (is (= x (-> x int-to-bytes bytes-to-int)))) 
+5
source

Avoid the need to write the expression (or dose) completely, using are to write the test.

+1
source

again bitten by a lazy mistake. need a map (dorun on the map :) * blush *

0
source

Source: https://habr.com/ru/post/1309931/


All Articles