mirror of https://github.com/phonopy/phono3py.git
Add ctest of gridsys_get_all_grid_addresses
This commit is contained in:
parent
02563428fa
commit
82b8685ae7
|
@ -6,27 +6,26 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
|
|||
|
||||
find_package(GTest)
|
||||
if(NOT GTest_FOUND)
|
||||
# pthread (required for GoogleTest)
|
||||
# https://stackoverflow.com/questions/1620918/cmake-and-libpthread
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
# pthread (required for GoogleTest)
|
||||
# https://stackoverflow.com/questions/1620918/cmake-and-libpthread
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
# Fetch GoogleTest
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
googletest
|
||||
URL https://github.com/google/googletest/archive/refs/tags/release-1.12.1.tar.gz
|
||||
URL_HASH MD5=e82199374acdfda3f425331028eb4e2a
|
||||
)
|
||||
FetchContent_MakeAvailable(googletest)
|
||||
# Fetch GoogleTest
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
googletest
|
||||
URL https://github.com/google/googletest/archive/refs/tags/release-1.12.1.tar.gz
|
||||
URL_HASH MD5=e82199374acdfda3f425331028eb4e2a)
|
||||
FetchContent_MakeAvailable(googletest)
|
||||
endif()
|
||||
|
||||
foreach(TESTCASE IN ITEMS
|
||||
test_kpoints
|
||||
)
|
||||
foreach(TESTCASE IN ITEMS test_gridsys)
|
||||
add_executable(${TESTCASE} ${TESTCASE}.cpp)
|
||||
target_link_libraries(${TESTCASE}
|
||||
PUBLIC gridsysmod
|
||||
PRIVATE GTest::gtest GTest::gtest_main)
|
||||
target_link_libraries(
|
||||
${TESTCASE}
|
||||
PUBLIC gridsys
|
||||
PRIVATE GTest::gtest GTest::gtest_main)
|
||||
target_include_directories(${TESTCASE} PUBLIC ${PROJECT_SOURCE_DIR}/c)
|
||||
gtest_discover_tests(${TESTCASE})
|
||||
endforeach()
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
extern "C" {
|
||||
#include "gridsys.h"
|
||||
}
|
||||
|
||||
TEST(test_gridsys, test_gridsys_get_all_grid_addresses) {
|
||||
long(*gr_grid_addresses)[3];
|
||||
long D_diag[3];
|
||||
long n;
|
||||
|
||||
D_diag[0] = 3;
|
||||
D_diag[1] = 4;
|
||||
D_diag[2] = 5;
|
||||
n = D_diag[0] * D_diag[1] * D_diag[2];
|
||||
gr_grid_addresses = (long(*)[3])malloc(sizeof(long[3]) * n);
|
||||
gridsys_get_all_grid_addresses(gr_grid_addresses, D_diag);
|
||||
}
|
||||
|
||||
/* TEST(test_gridsys, test_gridsys_get_all_grid_addresses) {
|
||||
double lattice[3][3] = {{4, 0, 0}, {0, 4, 0}, {0, 0, 3}};
|
||||
double position[][3] = {
|
||||
{0, 0, 0}, {0.5, 0.5, 0.5}, {0.3, 0.3, 0},
|
||||
{0.7, 0.7, 0}, {0.2, 0.8, 0.5}, {0.8, 0.2, 0.5},
|
||||
};
|
||||
int num_ir, retval;
|
||||
int types[] = {1, 1, 2, 2, 2, 2};
|
||||
int num_atom = 6;
|
||||
int m = 40;
|
||||
int mesh[3];
|
||||
int is_shift[] = {1, 1, 1};
|
||||
int(*grid_address)[3];
|
||||
int *grid_mapping_table;
|
||||
|
||||
mesh[0] = m;
|
||||
mesh[1] = m;
|
||||
mesh[2] = m;
|
||||
grid_address = (int(*)[3])malloc(sizeof(int[3]) * m * m * m);
|
||||
grid_mapping_table = (int *)malloc(sizeof(int) * m * m * m);
|
||||
|
||||
printf("*** spg_get_ir_reciprocal_mesh of Rutile structure ***:\n");
|
||||
|
||||
num_ir = spg_get_ir_reciprocal_mesh(grid_address, grid_mapping_table, mesh,
|
||||
is_shift, 1, lattice, position, types,
|
||||
num_atom, 1e-5);
|
||||
ASSERT_EQ(num_ir, 4200);
|
||||
|
||||
free(grid_address);
|
||||
grid_address = NULL;
|
||||
free(grid_mapping_table);
|
||||
grid_mapping_table = NULL;
|
||||
}
|
||||
*/
|
Loading…
Reference in New Issue