Search⌘ K
AI Features

Exercise: Create a Unit Test

Explore how to create effective unit tests in Clojure using the clojure.test framework. Learn to validate a function that calculates the minimum height of a triangle given area and base, incorporating both standard and edge cases. Gain hands-on practice with assertions and understand the testing process to ensure functional accuracy.

We'll cover the following...

Description

Unlike the other code challenges, this one won’t give you a grade or test the accuracy of what you’re doing. It will be your responsibility to validate if a function is properly implemented by creating a unit test for it.

The function that you’ll test will be the solution for the minimum height triangle solved in the following way:

Clojure
(defn minimum-height
[base area]
(int (Math/ceil (/ (* 2 area) base))))

We found the smallest integer that will be the value of the height of this triangle ...