Skip to content

Commit

Permalink
improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsch committed May 7, 2024
1 parent 46a488f commit fee2ad0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Hamiltonians/correlation_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ end
function Base.show(io::IO, g2::G2RealSpace{A,B}) where {A,B}
print(io, "G2RealSpace($(g2.geometry), $A,$B)")
end
function Base.show(io::IO, g2::G2RealSpace{0,0})
print(io, "G2RealSpace($(g2.geometry); sum_components=true)")
end

LOStructure(::Type{<:G2RealSpace}) = IsDiagonal()

Expand Down
17 changes: 17 additions & 0 deletions test/Hamiltonians.jl
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,23 @@ using Rimu.Hamiltonians: circshift_dot

@testset "G2RealSpace" begin
@testset "1D G2RealCorrelator comparison" begin
@testset "constructors" begin
g2_1 = G2RealSpace(Geometry(2, 2, 3), 1, 3) isa G2RealSpace{1,3}
g2_2 = G2RealSpace(Geometry(2, 2), 2) isa G2RealSpace{2,2}
g2_3 = G2RealSpace(Geometry(2, 2); sum_components=true) isa G2RealSpace{0,0}
@test g2_1 isa G2RealSpace{1,3}
@test g2_2 isa G2RealSpace{2,2}
@test g2_3 isa G2RealSpace{0,0}

@test eval(Meta.parse(repr(g2_1))) == g2_1
@test eval(Meta.parse(repr(g2_2))) == g2_2
@test eval(Meta.parse(repr(g2_3))) == g2_3

@test_throws ArgumentError G2RealSpace(Geometry(3), 1, 0)
@test_throws ArgumentError G2RealSpace(Geometry(2, 2), 0, 0)
@test_throws ArgumentError G2RealSpace(Geometry(1, 2, 3), -1, 2)
@test_throws ArgumentError G2RealSpace(Geometry(12), 3; sum_components=true)
end
@testset "single components" begin
addr = near_uniform(BoseFS{6,6})
H = HubbardReal1D(addr)
Expand Down

0 comments on commit fee2ad0

Please sign in to comment.