Skip to content

Commit 1d96e15

Browse files
committed
Test additional constructors
1 parent 2f1fd91 commit 1d96e15

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

test/unittests.jl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using DynamicQuantities
2-
using DynamicQuantities: DEFAULT_DIM_TYPE
2+
using DynamicQuantities: DEFAULT_DIM_TYPE, DEFAULT_VALUE_TYPE, DIMENSION_NAMES
33
using Ratios: SimpleRatio
44
using SaferIntegers: SafeInt16
55
using Test
@@ -136,6 +136,23 @@ end
136136
@test Quantity(0.5, length=2) / Dimensions(length=1) == Quantity(0.5, length=1)
137137
@test Dimensions(length=1) / Quantity(0.5, length=2, mass=-5) == Quantity(2, length=-1, mass=5)
138138

139+
@test Dimensions{Int8}([0 for i=1:length(DIMENSION_NAMES)]...) == Dimensions{Int8}()
140+
141+
@test zero(Quantity{ComplexF64,Int8}) + Quantity(1) == Quantity(1.0+0.0im, length=Int8(0))
142+
@test one(Quantity{ComplexF64,Int8}) - Quantity(1) == Quantity(0.0+0.0im, length=Int8(0))
143+
@test typeof(one(Dimensions{Int16})) == Dimensions{Int16}
144+
@test one(Dimensions{Int16}) == Dimensions(mass=Int16(0))
145+
146+
@test zero(Quantity{ComplexF64}) == Quantity(0.0+0.0im)
147+
@test one(Quantity{ComplexF64}) == Quantity(1.0+0.0im)
148+
149+
@test zero(Quantity) == Quantity(0.0)
150+
@test typeof(zero(Quantity)) == Quantity{DEFAULT_VALUE_TYPE,DEFAULT_DIM_TYPE}
151+
@test one(Quantity) - Quantity(1) == Quantity(0.0)
152+
@test typeof(one(Quantity)) == Quantity{DEFAULT_VALUE_TYPE,DEFAULT_DIM_TYPE}
153+
@test typeof(one(Dimensions)) == Dimensions{DEFAULT_DIM_TYPE}
154+
@test one(Dimensions) == Dimensions()
155+
139156
@test sqrt(z * -1) == Quantity(sqrt(52), length=1 // 2, mass=1)
140157
@test cbrt(z) == Quantity(cbrt(-52), length=1 // 3, mass=2 // 3)
141158

0 commit comments

Comments
 (0)