Skip to content

Commit 4410d78

Browse files
authored
Add tests for units.jl (#62)
1 parent 6405136 commit 4410d78

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ include("support/util.jl")
1515
"SampleBuf.jl",
1616
"SampleStream.jl",
1717
"SinSource.jl",
18+
"units.jl"
1819
# "WAVDisplay.jl"
1920
])
2021
end

test/units.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
@test inseconds(1.0s,44100Hz) == 1.0
99
@test inseconds(10ms,44100Hz) == 1//100
1010
@test inseconds(1.0,44100Hz) == 1.0
11+
@test inseconds(1.0,44100Hz) == inseconds(1.0)
12+
@test_throws ErrorException inseconds(441frames)
1113
end
1214

1315
@testset "converting to frames" begin
@@ -17,13 +19,20 @@
1719
@test inframes(10.5frames,44100Hz) == 10.5
1820
@test inframes(10frames) == 10
1921
@test inframes(10) == 10
22+
@test inframes(1s, 44100) == inframes(1000ms,44100Hz)
23+
@test inframes(10Hz, 0.1) == 1
24+
@test inframes(Int, 1) == inframes(1)
2025
@test_throws ErrorException inframes(1s)
26+
@test_throws ErrorException inframes(Int, 1s)
2127
end
2228

2329
@testset "converting to Hz" begin
2430
@test inHz(100Hz) == inHz(0.1kHz)
2531
@test inHz(100Hz) == 100
2632
@test inHz(1kHz) == 1000
2733
@test inHz(100) == 100
34+
@test inHz(441frames, 1000) == 0.441
35+
@test inHz(1.0, 441000) == inHz(1.0)
36+
@test_throws ErrorException inHz(441frames)
2837
end
2938
end

0 commit comments

Comments
 (0)