44* Tests cover:
55* > mandatory messaging, send/recieve
66*/
7+ #include < array>
78#include < unordered_map>
8-
99#include " flamegpu/flamegpu.h"
10-
1110#include " gtest/gtest.h"
1211
1312namespace flamegpu {
1413
15-
1614namespace test_message_spatial3d {
1715
1816FLAMEGPU_AGENT_FUNCTION (out_mandatory3D, MessageNone, MessageSpatial3D) {
@@ -900,7 +898,7 @@ FLAMEGPU_AGENT_FUNCTION(inWrapped3D, MessageSpatial3D, MessageNone) {
900898void wrapped_3d_test (const float x_offset, const float y_offset, const float z_offset, const float out_of_bounds = 0 ) {
901899 std::unordered_map<int , unsigned int > bin_counts;
902900 // Construct model
903- ModelDescription model (" Spatial2DMessageTestModel " );
901+ ModelDescription model (" Spatial3DMessageTestModel " );
904902 { // Location message
905903 MessageSpatial3D::Description message = model.newMessage <MessageSpatial3D>(" location" );
906904 message.setMin (0 + x_offset, 0 + y_offset, 0 + z_offset);
@@ -987,15 +985,12 @@ FLAMEGPU_AGENT_FUNCTION(in_wrapped_EnvDimsNotFactor, MessageSpatial3D, MessageNo
987985 }
988986 return ALIVE;
989987}
990- TEST (Spatial3DMessageTest, Wrapped_EnvDimsNotFactor) {
991- // This tests that bug #1157 is fixed
992- // When the interaction radius is not a factor of the width
993- // that agent's near the max env bound all have the full interaction radius
988+ void wrapped_3d_test_bounds (std::array<float , 3 > lower, std::array<float , 3 > upper, float radius, bool exceptionExpected) {
994989 ModelDescription m (" model" );
995990 MessageSpatial3D::Description message = m.newMessage <MessageSpatial3D>(" location" );
996- message.setMin (0 , 0 , 0 );
997- message.setMax (50 . 1f , 50 . 1f , 50 . 1f );
998- message.setRadius (10 );
991+ message.setMin (lower. at ( 0 ), lower. at ( 1 ), lower. at ( 2 ) );
992+ message.setMax (upper. at ( 0 ), upper. at ( 1 ), upper. at ( 2 ) );
993+ message.setRadius (radius );
999994 message.newVariable <flamegpu::id_t >(" id" ); // unused by current test
1000995 AgentDescription agent = m.newAgent (" agent" );
1001996 agent.newVariable <float >(" x" );
@@ -1017,12 +1012,25 @@ TEST(Spatial3DMessageTest, Wrapped_EnvDimsNotFactor) {
10171012 // Vertical pair that can interact
10181013 // Top side
10191014 AgentVector::Agent i1 = population[0 ];
1020- i1.setVariable <float >(" x" , 25 . 0f );
1021- i1.setVariable <float >(" y" , 25 . 0f );
1022- i1.setVariable <float >(" z" , 25 . 0f );
1015+ i1.setVariable <float >(" x" , upper. at ( 0 ) );
1016+ i1.setVariable <float >(" y" , upper. at ( 1 ) );
1017+ i1.setVariable <float >(" z" , upper. at ( 2 ) );
10231018 c.setPopulationData (population);
10241019 c.SimulationConfig ().steps = 1 ;
1025- EXPECT_THROW (c.simulate (), exception::DeviceError);
1020+ if (exceptionExpected) {
1021+ EXPECT_THROW (c.simulate (), exception::DeviceError);
1022+ } else {
1023+ EXPECT_NO_THROW (c.simulate ());
1024+ }
1025+ }
1026+ TEST (Spatial3DMessageTest, Wrapped_EnvDimsNotFactor) {
1027+ // This tests that bug #1157 is fixed
1028+ // When the interaction radius is not a factor of the width
1029+ // that agent's near the max env bound all have the full interaction radius
1030+ wrapped_3d_test_bounds ({0 , 0 , 0 }, {50 .1f , 50 .1f , 50 .1f }, 10 , true );
1031+ // also includes a number of potential edge cases to ensure that no false positives are included (#1177)
1032+ wrapped_3d_test_bounds ({0 , 0 , 0 }, {1 , 1 , 1 }, 0 .05f , false );
1033+ wrapped_3d_test_bounds ({0 , 0 , 0 }, {3 , 2 , 1 }, 0 .05f , false );
10261034}
10271035#else
10281036TEST (Spatial3DMessageTest, DISABLED_Wrapped_OutOfBounds) { }
0 commit comments