update HalfInteger

This commit is contained in:
Jutho 2018-10-05 17:20:22 +02:00
parent 8854cfbb97
commit 39bbd0ced8
2 changed files with 38 additions and 3 deletions

View file

@ -2,9 +2,37 @@ using Test
using WignerSymbols
using LinearAlgebra
using WignerSymbols: HalfInteger
smalljlist = 0:1//2:10
largejlist = 0:1//2:1000
@testset "HalfInteger" begin
@test convert(HalfInteger, 2) == HalfInteger(4)
@test convert(HalfInteger, 1//2) == HalfInteger(1)
@test convert(HalfInteger, 1.5) == HalfInteger(3)
@test_throws InexactError convert(HalfInteger, 1//3)
@test_throws InexactError convert(HalfInteger, 0.6)
@test convert(HalfInteger, 2) == 2
@test convert(HalfInteger, 1//2) == 1//2
@test convert(HalfInteger, 1.5) == 1.5
@test_throws InexactError convert(Integer, HalfInteger(1))
a = HalfInteger(4)
b = HalfInteger(3)
@test a + b == 2 + 3//2
@test a - b == 2 - 3//2
@test zero(a) == 0
@test one(a) == 1
@test a > b
@test b < a
@test b <= a
@test a >= b
@test a == a
@test a != b
@test hash(a) == hash(2)
@test hash(b) == hash(1.5)
@test hash(b) == hash(3//2)
end
@testset "triangle coefficient" begin
for j1 in smalljlist, j2 in smalljlist
for j3 = abs(j1-j2):(j1+j2)