# -*- coding: utf-8 -*- from kvadratisk import kvadratisk from numpy import isclose from math import sqrt def test_kvadratisk1(): (x1,x2) = kvadratisk(1,0,-1) # skal gi +1 og -1 som l?sninger success = isclose(x1, -1) and isclose(x2, 1) msg = "kvadratisk() feilet: (x1,x2 = %f,%f), riktig er (-1,1)" % (x1,x2) assert success, msg def test_kvadratisk2(): (x1,x2) = kvadratisk(2,-1,-1) x1correct = -0.5 x2correct = 1.0 success = isclose(x1, x1correct) and isclose(x2, x2correct) msg = "kvadratisk() feilet: (x1,x2 = %f,%f), riktig er (%f,%f)" % (x1,x2,x1correct,x2correct) assert success, msg