Advertisement
Guest User

Untitled

a guest
Nov 27th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (ns lab5.integral-test
  2.   (:require [clojure.test :refer :all]
  3.             [lab5.integral :refer :all]))
  4.  
  5. (deftest trapezoid-area-test
  6.   (testing "Вычислить площадь трапеции"
  7.     (is (= 6 (trapezoid-area (fn [x] x) 2 4)))
  8.     (is (= 5/2 (trapezoid-area (fn [x] (* x x)) 1 2)))
  9.     (is (= 16 (trapezoid-area (fn [x] (* x x)) -2 2)))
  10.   )
  11. )
  12.  
  13. (deftest integrate-test
  14.   (testing "Проинтегрировать функцию методом трапеций"
  15.     (is (= 25/2 ((make-integral (fn [x] x) 1) 5)))
  16.     (is (= 19/2 ((make-integral (fn [x] (* x x)) 1) 3)))
  17.     (is (= 25/2 ((make-integral (fn [x] x) 1/10) 5)))
  18.     (is (= 1801/200 ((make-integral (fn [x] (* x x)) 1/10) 3)))
  19.     (let
  20.       [
  21.         function (fn [x] 1)
  22.         antiderivative (fn [x] x)
  23.       ] (is (= (antiderivative 10) ((make-integral function 1) 10)))
  24.     )
  25.   )
  26. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement