|
1 | 1 | using Test |
2 | 2 |
|
3 | | -@testset "conversion" begin |
| 3 | +@testset "Construction and Conversion" begin |
| 4 | + for VT in [Point, Vec] |
| 5 | + for T in [Int32, Float32, Float64, UInt16, BigFloat] |
| 6 | + p = VT{3, T}(1,2,3) |
| 7 | + @test p[1] == T(1) |
| 8 | + @test p[2] == T(2) |
| 9 | + @test p[3] == T(3) |
| 10 | + end |
| 11 | + |
| 12 | + for VT2 in [Point, Vec] |
| 13 | + @test VT{2, Float32}(VT2{3, Float32}(1,2,3)) == VT{2, Float32}(1,2) |
| 14 | + @test VT{2, Float32}(VT2{3, Float64}(1,2,3)) == VT{2, Float32}(1,2) |
| 15 | + end |
| 16 | + @test VT{2, Float32}(Float32[1,2,3]) == VT{2, Float32}(1,2) |
| 17 | + @test VT{2, Float32}([1,2,3]) == VT{2, Float32}(1,2) |
| 18 | + end |
| 19 | + |
4 | 20 | @test convert(Point, (2, 3)) === Point(2, 3) |
5 | 21 | @test convert(Point, (2.0, 3)) === Point(2.0, 3.0) |
6 | 22 | end |
|
17 | 33 | T = ifelse(T1 == Point, Point, ifelse(T2 == Point, Point, Vec)) |
18 | 34 | @test T(2, 2, 4) == T1(1,2,3) .+ T2(1, 0, 1) |
19 | 35 | @test T(foo.((1,2,3), (1, 0, 1))) == foo.(T1(1,2,3), T2(1, 0, 1)) |
| 36 | + @test T1(1,2,3) .* T2(1,2,3) == T(1, 4, 9) |
| 37 | + # TODO: repair this: |
| 38 | + # @test foo.(T1(1,2,3), [T2(1,1,1), T2(2,2,2)]) == [T(1,2,3), T(2,4,6)] |
| 39 | + # @test foo.([T2(1,1,1), T2(2,2,2)], T1(1,2,3)) == [T(0, -3, -8), T(3, 0, -5)] |
20 | 40 | end |
21 | 41 | end |
22 | 42 |
|
|
51 | 71 | for T2 in (Vec, Point, tuple) |
52 | 72 | T1 == tuple && T2 == tuple && continue |
53 | 73 | T = ifelse(T1 == Point, Point, ifelse(T2 == Point, Point, Vec)) |
54 | | - @test T(foo2.((1,2,3), (1, 0, 1), (3, 2, 1), (2,2,0))) == |
| 74 | + @test T(foo2.((1,2,3), (1, 0, 1), (3, 2, 1), (2,2,0))) == |
55 | 75 | foo2.(T1(1,2,3), T2(1, 0, 1), T2(3, 2, 1), T2(2,2,0)) |
56 | 76 | end |
57 | 77 | end |
|
80 | 100 | @testset "Mat" begin |
81 | 101 | M3 = Mat3(1,2,3, 4,5,6, 7,8,9) |
82 | 102 | @test M3 isa Mat{3,3,Int,9} |
83 | | - |
| 103 | + |
84 | 104 | @testset "indexing" begin |
85 | 105 | for i in 1:9 |
86 | 106 | @test getindex(M3, i) == i |
|
0 commit comments