-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add tests for NoDims type and refactored ope
- Loading branch information
1 parent
a8ab0c0
commit af498af
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |