Skip to content

Commit 5576de1

Browse files
committed
Add tests
1 parent 5331823 commit 5576de1

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

test/test_basics.jl

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
using ITensorBase:
2-
ITensorBase, ITensor, Index, gettag, hastag, inds, plev, prime, settag, tags, unsettag
2+
ITensorBase,
3+
ITensor,
4+
Index,
5+
gettag,
6+
hastag,
7+
inds,
8+
oneelement,
9+
plev,
10+
prime,
11+
settag,
12+
tags,
13+
unsettag
314
using DiagonalArrays: δ, delta, diagview
415
using NamedDimsArrays: dename, name, named
516
using Test: @test, @test_broken, @testset
@@ -35,6 +46,27 @@ using Test: @test, @test_broken, @testset
3546
@test plev(i) == 0
3647
@test length(tags(i)) == 0
3748
end
49+
@testset "oneelement" begin
50+
i = Index(3)
51+
a = oneelement(i => 2)
52+
@test a isa ITensor
53+
@test ndims(a) == 1
54+
@test issetequal(inds(a), (i,))
55+
@test eltype(a) === Bool
56+
@test a[1] == 0
57+
@test a[2] == 1
58+
@test a[3] == 0
59+
60+
i = Index(3)
61+
a = oneelement(Float32, i => 2)
62+
@test a isa ITensor
63+
@test ndims(a) == 1
64+
@test issetequal(inds(a), (i,))
65+
@test eltype(a) === Float32
66+
@test a[1] == 0
67+
@test a[2] == 1
68+
@test a[3] == 0
69+
end
3870
@testset "delta" begin
3971
i, j = Index.((2, 2))
4072
for a in (

0 commit comments

Comments
 (0)