Skip to content

Commit 44f7ade

Browse files
authored
Add Aqua.jl in test (#238)
* add method for QuatRotation to remove ambiguities * add Aqua.jl * add ForwardDiff in test/Project.toml * add BenchmarkTools in test/Project.toml * add tests for QuatRotation(SVector(1, 2, 3, 4, 5))
1 parent e34142d commit 44f7ade

File tree

5 files changed

+22
-15
lines changed

5 files changed

+22
-15
lines changed

Project.toml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,3 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1313
Quaternions = "0.5.3"
1414
StaticArrays = "1.2.12"
1515
julia = "1.6"
16-
17-
[extras]
18-
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
19-
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
20-
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
21-
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
22-
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
23-
24-
[targets]
25-
test = ["BenchmarkTools", "ForwardDiff", "Test", "InteractiveUtils", "Unitful"]

src/unitquaternion.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ end
7777
@inline function (::Type{Q})(q::StaticVector{4}, normalize::Bool = true) where Q <: QuatRotation
7878
Q(q[1], q[2], q[3], q[4], normalize)
7979
end
80+
function (::Type{Q})(q::StaticArray{S, T, 1} where {S<:Tuple, T}, normalize::Bool = true) where Q <: QuatRotation
81+
# This method is just for avoiding ambiguities.
82+
error("The input vector $q must have 4 elements.")
83+
end
8084

8185
# Copy constructors
8286
QuatRotation(q::QuatRotation) = q

test/Project.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[deps]
2+
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
3+
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
4+
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
5+
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
6+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
7+
Quaternions = "94ee1d12-ae83-5a48-8b1c-48b8ff168ae0"
8+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
9+
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
10+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
11+
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
12+
13+
[compat]
14+
Aqua = "0.5"

test/runtests.jl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@ using Rotations
44
using StaticArrays
55
using InteractiveUtils: subtypes
66
using Quaternions
7+
using Aqua
78
import Unitful
8-
99
import Random
1010

11-
# Check that there are no ambiguities beyond those present in StaticArrays
12-
ramb = detect_ambiguities(Rotations, Base, Core)
13-
samb = detect_ambiguities(StaticArrays, Base, Core)
14-
@test isempty(setdiff(ramb, samb))
11+
Aqua.test_all(Rotations)
1512

1613
include("util_tests.jl")
1714
include("2d.jl")

test/unitquat.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ import Rotations: vmat, rmult, lmult, hmat, tmat
6565
@test 2 * q == 2 * Matrix(q)
6666
@test q * 2 == 2 * Matrix(q)
6767

68+
@test_throws ErrorException QuatRotation(SVector(1, 2, 3, 4, 5))
69+
6870
# Axis-angle
6971
ϕ = 0.1 * @SVector [1, 0, 0]
7072
q = expm(ϕ)

0 commit comments

Comments
 (0)