-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #185 from singularitti:singularitti/issue183
Add tests to `get_error_code`
- Loading branch information
Showing
3 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Spglib: | ||
SUCCESS, | ||
SPACEGROUP_SEARCH_FAILED, | ||
NIGGLI_FAILED, | ||
DELAUNAY_FAILED, | ||
CELL_STANDARDIZATION_FAILED, | ||
ATOMS_TOO_CLOSE, | ||
get_error_code | ||
|
||
@testset "Test when no error occurs" begin | ||
lattice = [[0.0, 0.5, 0.5], [0.5, 0.0, 0.5], [0.5, 0.5, 0.0]] * 5.4 | ||
positions = [[0.875, 0.875, 0.875], [0.125, 0.125, 0.125]] | ||
atoms = [1, 1] | ||
cell = Cell(lattice, positions, atoms) | ||
get_dataset(cell, 1e-5) | ||
@test get_error_code() == SUCCESS | ||
end | ||
|
||
@testset "Test error types" begin | ||
lattice = Lattice([[0.5, 0.5, 0.0], [0.5, 0.0, 0.5], [0.5, 0.5, 0.0]] * 5.4) | ||
positions = [[0.875, 0.875, 0.875], [0.125, 0.125, 0.125]] | ||
atoms = [1, 1] | ||
cell = Cell(lattice, positions, atoms) | ||
@test_throws SpglibError get_dataset(cell, 1e-5) | ||
@test get_error_code() == SPACEGROUP_SEARCH_FAILED | ||
@test_throws SpglibError niggli_reduce(cell, 1e-5) | ||
@test get_error_code() == NIGGLI_FAILED | ||
@test_throws SpglibError delaunay_reduce(cell, 1e-5) | ||
@test get_error_code() == DELAUNAY_FAILED | ||
@test_throws SpglibError standardize_cell(cell, 1e-5) | ||
@test get_error_code() == CELL_STANDARDIZATION_FAILED | ||
@testset "Test when atoms are too close" begin | ||
positions = [[0.875, 0.875, 0.875], [0.875 + eps(), 0.875, 0.875]] | ||
cell = Cell(lattice, positions, atoms) | ||
@test_throws SpglibError get_dataset(cell, 1e-5) | ||
@test get_error_code() == ATOMS_TOO_CLOSE | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ using Test | |
include("reciprocal.jl") | ||
include("reduce.jl") | ||
include("symmetry.jl") | ||
include("error.jl") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters