Skip to content

Commit

Permalink
Add "Test example from AtomsBase.jl documentation" in test/AtomsBase.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
singularitti committed Oct 18, 2023
1 parent 5770b4a commit 4a7aa15
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/AtomsBase.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using AtomsBase
using Unitful: ustrip, @u_str
using UnitfulLinearAlgebra

# See https://juliamolsim.github.io/AtomsBase.jl/stable/tutorial/#System-interface-and-conventions v0.3.5
@testset "Test example from AtomsBase.jl documentation" begin
box = [[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]u"Å" # Note the unit!
bc = [Periodic(), Periodic(), Periodic()]
hydrogen = FlexibleSystem(
[Atom(:H, [0, 0, 1.0]u"bohr"), Atom(:H, [0, 0, 3.0]u"bohr")], box, bc
)
cell = Cell(
box, [[0, 0, ustrip(u"Å", 0.1u"bohr")], [0, 0, ustrip(u"Å", 0.3u"bohr")]], [:H, :H]
)
@test Cell(hydrogen) == cell
@test all(
position(FlexibleSystem(cell)) .≈
[uconvert.(u"Å", [0, 0, 1.0]u"bohr"), uconvert.(u"Å", [0, 0, 3.0]u"bohr")],
)
end
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ using Test
# Write your tests here.
include("lattice.jl")
include("eachatom.jl")
include("AtomsBase.jl")
end

0 comments on commit 4a7aa15

Please sign in to comment.