Cleanup code slightly and implement tests for CellList
Some checks failed
Build and Test / build-and-test (push) Failing after 5m4s
Some checks failed
Build and Test / build-and-test (push) Failing after 5m4s
This commit is contained in:
parent
f3e701236e
commit
d957a90573
4 changed files with 55 additions and 7 deletions
|
@ -4,6 +4,7 @@ add_executable(${NAME}_cuda_tests
|
|||
test_potential.cu
|
||||
test_forces.cu
|
||||
test_kernel_config.cu
|
||||
test_neighbor_list.cu
|
||||
)
|
||||
|
||||
target_link_libraries(${NAME}_cuda_tests gtest gtest_main)
|
||||
|
|
31
tests/cuda_unit_tests/test_neighbor_list.cu
Normal file
31
tests/cuda_unit_tests/test_neighbor_list.cu
Normal file
|
@ -0,0 +1,31 @@
|
|||
|
||||
#include "box.hpp"
|
||||
#include "neighbor_list.cuh"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
TEST(CellListTest, Constructor) {
|
||||
// Test case 1: Simple case
|
||||
Box box(0, 10, 0, 10, 0, 10);
|
||||
float cutoff = 2.5;
|
||||
CellList cell_list(100, box, cutoff);
|
||||
|
||||
EXPECT_EQ(cell_list.grid_size.x, 4);
|
||||
EXPECT_EQ(cell_list.grid_size.y, 4);
|
||||
EXPECT_EQ(cell_list.grid_size.z, 4);
|
||||
EXPECT_FLOAT_EQ(cell_list.cell_size.x, 2.5);
|
||||
EXPECT_FLOAT_EQ(cell_list.cell_size.y, 2.5);
|
||||
EXPECT_FLOAT_EQ(cell_list.cell_size.z, 2.5);
|
||||
EXPECT_EQ(cell_list.total_cells, 64);
|
||||
}
|
||||
|
||||
TEST(CellListTest, GetCellIndex) {
|
||||
Box box(0, 10, 0, 10, 0, 10);
|
||||
float cutoff = 2.5;
|
||||
CellList cell_list(100, box, cutoff);
|
||||
|
||||
int x = 1, y = 2, z = 3;
|
||||
int expected_index = z * cell_list.grid_size.x * cell_list.grid_size.y +
|
||||
y * cell_list.grid_size.x + x;
|
||||
|
||||
EXPECT_EQ(cell_list.get_cell_index(x, y, z), expected_index);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue