Skip to content

Commit 37b41a3

Browse files
committed
Add one(Dimensions)
1 parent d3e6a27 commit 37b41a3

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/utils.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Base.iterate(q::Quantity) = (q, nothing)
4747
Base.iterate(::Quantity, ::Nothing) = nothing
4848
Base.zero(::Type{Quantity{T}}) where {T} = Quantity(zero(T))
4949
Base.one(::Type{Quantity{T}}) where {T} = Quantity(one(T))
50+
Base.one(::Type{Dimensions}) = Dimensions()
5051

5152
Base.show(io::IO, d::Dimensions) =
5253
let tmp_io = IOBuffer()

test/unittests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ using Test
9797
@test one(Quantity{String}) == Quantity("")
9898
@test zero(Quantity{Float64}) == Quantity(0.0)
9999
@test zero(Quantity{Int}) == Quantity(0, length=0, mass=0)
100+
@test Quantity(1.0, one(Dimensions)) == Quantity(1.0)
101+
@test one(Dimensions) == Dimensions()
100102
end
101103

102104
@testset "Fallbacks" begin

0 commit comments

Comments
 (0)