Skip to content

Commit

Permalink
Make tests more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
saschatimme committed Jun 22, 2019
1 parent 2e17a73 commit 303bdf2
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions test/codegen_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,38 +35,39 @@

@testset "evalpoly_deriv" begin
z = rand(Complex{Float64})
tol = 1e-12
for T in [Float64, Complex{Float64}]
c0, c1, c2, c3, c4, c5 = rand(T, 6)

true_val = c0 + c1 * z + c2 * z^2 + c3 * z^3 + c4 * z^4 + c5 * z^5
true_dval = c1 + 2c2 * z + 3c3 * z^2 + 4c4 * z^3 + 5c5 * z^4
val, dval = SP.@goertzel_deriv z c0 c1 c2 c3 c4 c5
@test abs(val - true_val) < 1e-14
@test abs(dval - true_dval) < 1e-14
@test abs(val - true_val) < tol
@test abs(dval - true_dval) < tol
val, dval = SP.@horner_deriv z c0 c1 c2 c3 c4 c5
@test abs(val - true_val) < 1e-14
@test abs(dval - true_dval) < 1e-14
@test abs(val - true_val) < tol
@test abs(dval - true_dval) < tol
val, dval = SP.@evalpoly_derivative z c0 c1 c2 c3 c4 c5
@test abs(val - true_val) < 1e-14
@test abs(dval - true_dval) < 1e-14
@test abs(val - true_val) < tol
@test abs(dval - true_dval) < tol

true_val = c0 + c1 * z + c2 * z^2
true_dval = c1 + 2c2 * z
val, dval = SP.@goertzel_deriv z c0 c1 c2
@test abs(val - true_val) < 1e-14
@test abs(dval - true_dval) < 1e-14
@test abs(val - true_val) < tol
@test abs(dval - true_dval) < tol
val, dval = SP.@horner_deriv z c0 c1 c2
@test abs(val - true_val) < 1e-14
@test abs(dval - true_dval) < 1e-14
@test abs(val - true_val) < tol
@test abs(dval - true_dval) < tol

true_val = c0 + c1 * z
true_dval = c1
val, dval = SP.@goertzel_deriv z c0 c1
@test abs(val - true_val) < 1e-14
@test abs(dval - true_dval) < 1e-14
@test abs(val - true_val) < tol
@test abs(dval - true_dval) < tol
val, dval = SP.@horner_deriv z c0 c1
@test abs(val - true_val) < 1e-14
@test abs(dval - true_dval) < 1e-14
@test abs(val - true_val) < tol
@test abs(dval - true_dval) < tol
end
end

Expand Down

0 comments on commit 303bdf2

Please sign in to comment.