Skip to content

Commit

Permalink
feat: Add tests for NoDims type and refactored ope
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] committed Nov 20, 2023
1 parent a8ab0c0 commit af498af
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/nodims.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Test
using DynamicQuantities

@testset "NoDims" begin
@test dimension() isa NoDims
end

@testset "Operators with NoDims" begin
q1 = Quantity(3.0, NoDims)
q2 = Quantity(4.0, NoDims)

@test q1 + q2 == Quantity(7.0, NoDims)
@test q1 - q2 == Quantity(-1.0, NoDims)
@test q1 * q2 == Quantity(12.0, NoDims)
@test q1 / q2 == Quantity(0.75, NoDims)

@test q1 + 2 == Quantity(5.0, NoDims)
@test q1 - 2 == Quantity(1.0, NoDims)
@test q1 * 2 == Quantity(6.0, NoDims)
@test q1 / 2 == Quantity(1.5, NoDims)

@test 2 + q1 == Quantity(5.0, NoDims)
@test 2 - q1 == Quantity(-1.0, NoDims)
@test 2 * q1 == Quantity(6.0, NoDims)
@test 2 / q1 == Quantity(2/3, NoDims)

@test q1 + Inf == Quantity(Inf, NoDims)
@test q1 - Inf == Quantity(-Inf, NoDims)
@test q1 * Inf == Quantity(Inf, NoDims)
@test q1 / Inf == Quantity(0.0, NoDims)

@test isnan((q1 + NaN).value)
@test isnan((q1 - NaN).value)
@test isnan((q1 * NaN).value)
@test isnan((q1 / NaN).value)
end

0 comments on commit af498af

Please sign in to comment.