diff --git a/scripts/cmake-presets/ci-windows-github.json b/scripts/cmake-presets/ci-windows-github.json index 56e22decf6..abb6b3dd4c 100644 --- a/scripts/cmake-presets/ci-windows-github.json +++ b/scripts/cmake-presets/ci-windows-github.json @@ -39,7 +39,7 @@ "inherits": ["base"], "displayName": "fast build with testing and JSON", "cacheVariables": { - "CELERITAS_BUILD_TESTS": {"type": "BOOL", "value": "OFF"}, + "CELERITAS_BUILD_TESTS": {"type": "BOOL", "value": "ON"}, "CELERITAS_USE_JSON": {"type": "BOOL", "value": "ON"} } }, diff --git a/test/TestMacros.test.cc b/test/TestMacros.test.cc index f9e0035a9f..5c95ef0b0c 100644 --- a/test/TestMacros.test.cc +++ b/test/TestMacros.test.cc @@ -329,22 +329,22 @@ TEST(IsVecEq, failures) IsVecEq("expectedddddddddd", "actualllllllllll", expected, actual)); // multiple wrong values - expected.push_back(100.); - actual.push_back(102.); + expected.push_back(100); + actual.push_back(102); EXPECT_FALSE(IsVecEq("expected", "actual", expected, actual)); EXPECT_FALSE(IsVecEq("static_array", "actual", static_array, actual)); // Ten wrong values - expected.assign(10, 5.); - actual.assign(10, 6.); + expected.assign(10, 5); + actual.assign(10, 6); EXPECT_FALSE(IsVecEq("expected", "actual", expected, actual)); // Uncomment this line to test output // EXPECT_VEC_EQ(expected, actual); // 100 wrong values (should truncate) - expected.assign(100, 5.); - actual.assign(100, 6.); + expected.assign(100, 5); + actual.assign(100, 6); EXPECT_FALSE(IsVecEq("expected", "actual", expected, actual)); // A couple of wrong values in a large array diff --git a/test/celeritas/em/CombinedBrem.test.cc b/test/celeritas/em/CombinedBrem.test.cc index 0db4a1d922..0a49df87dd 100644 --- a/test/celeritas/em/CombinedBrem.test.cc +++ b/test/celeritas/em/CombinedBrem.test.cc @@ -254,7 +254,7 @@ TEST_F(CombinedBremTest, basic_relativistic_brem) TEST_F(CombinedBremTest, stress_test_combined) { - int const num_samples = 1e4; + int const num_samples = 10000; std::vector avg_engine_samples; std::vector avg_energy_samples; diff --git a/test/celeritas/em/Fluctuation.test.cc b/test/celeritas/em/Fluctuation.test.cc index 6c2f817fd2..a5a15ec214 100644 --- a/test/celeritas/em/Fluctuation.test.cc +++ b/test/celeritas/em/Fluctuation.test.cc @@ -271,16 +271,17 @@ TEST_F(EnergyLossDistributionTest, urban) counts[bin]++; sum += loss; } - - if (CELERITAS_REAL_TYPE == CELERITAS_REAL_TYPE_DOUBLE) - { - static real_type const expected_counts[] - = {0, 0, 12, 223, 1174, 2359, 2661, 1867, 898, 369, - 189, 107, 60, 48, 20, 9, 2, 2, 0, 0}; - EXPECT_VEC_SOFT_EQ(expected_counts, counts); - EXPECT_SOFT_EQ(0.0099918954960280353, sum / num_samples); - EXPECT_EQ(551188, rng.count()); - } +#ifdef _MSC_VER + // TODO: determine why the sampled sequence is different + GTEST_SKIP() << "Results differ statistically when built with MSVC..."; +#endif + + static real_type const expected_counts[] + = {0, 0, 12, 223, 1174, 2359, 2661, 1867, 898, 369, + 189, 107, 60, 48, 20, 9, 2, 2, 0, 0}; + EXPECT_VEC_SOFT_EQ(expected_counts, counts); + EXPECT_SOFT_EQ(0.0099918954960280353, sum / num_samples); + EXPECT_EQ(551188, rng.count()); } //---------------------------------------------------------------------------// } // namespace test diff --git a/test/celeritas/em/KleinNishina.test.cc b/test/celeritas/em/KleinNishina.test.cc index 6d39d0b953..0442d165d3 100644 --- a/test/celeritas/em/KleinNishina.test.cc +++ b/test/celeritas/em/KleinNishina.test.cc @@ -221,15 +221,15 @@ TEST_F(KleinNishinaInteractorTest, distributions) Interaction out = interact(rng_engine); // Bin energy loss double eps = out.energy.value() / inc_energy; - int eps_bin = eps * nbins; + int eps_bin = static_cast(std::floor(eps * nbins)); if (eps_bin >= 0 && eps_bin < nbins) { ++eps_dist[eps_bin]; } - // Bin directional change + // Bin directional change, remapping from [-1,1] to [0,1] double costheta = dot_product(inc_direction, out.direction); - int ct_bin = (1 + costheta) / 2 * nbins; // Remap from [-1,1] to [0,1] + int ct_bin = static_cast(std::floor((1 + costheta) / 2 * nbins)); if (ct_bin >= 0 && ct_bin < nbins) { ++costheta_dist[ct_bin]; diff --git a/test/celeritas/em/LivermorePE.test.cc b/test/celeritas/em/LivermorePE.test.cc index 6b8645024e..1348e64254 100644 --- a/test/celeritas/em/LivermorePE.test.cc +++ b/test/celeritas/em/LivermorePE.test.cc @@ -356,7 +356,7 @@ TEST_F(LivermorePETest, distributions_all) // Bin directional change of the photoelectron real_type costheta = dot_product(inc_direction, out.secondaries.front().direction); - int ct_bin = (1 + costheta) / 2 * nbins; // Remap from [-1,1] to [0,1] + int ct_bin = static_cast(std::floor((1 + costheta) / 2 * nbins)); if (ct_bin >= 0 && ct_bin < nbins) { ++costheta_dist[ct_bin]; diff --git a/test/celeritas/em/MollerBhabha.test.cc b/test/celeritas/em/MollerBhabha.test.cc index 2c3065b598..bd7dce0fd4 100644 --- a/test/celeritas/em/MollerBhabha.test.cc +++ b/test/celeritas/em/MollerBhabha.test.cc @@ -311,7 +311,7 @@ TEST_F(MollerBhabhaInteractorTest, cutoff_1MeV) //---------------------------------------------------------------------------// TEST_F(MollerBhabhaInteractorTest, stress_test) { - int const num_samples = 1e4; + int const num_samples = 10000; std::vector avg_engine_samples; CutoffView cutoff_view(this->cutoff_params()->host_ref(), MaterialId{0}); diff --git a/test/celeritas/em/MuBremsstrahlung.test.cc b/test/celeritas/em/MuBremsstrahlung.test.cc index 5960ad5b07..b043f037cd 100644 --- a/test/celeritas/em/MuBremsstrahlung.test.cc +++ b/test/celeritas/em/MuBremsstrahlung.test.cc @@ -135,7 +135,7 @@ TEST_F(MuBremsstrahlungInteractorTest, basic) TEST_F(MuBremsstrahlungInteractorTest, stress_test) { - unsigned int const num_samples = 1e4; + unsigned int const num_samples = 10000; std::vector avg_engine_samples; for (auto particle : {pdg::mu_minus(), pdg::mu_plus()}) diff --git a/test/celeritas/em/SeltzerBerger.test.cc b/test/celeritas/em/SeltzerBerger.test.cc index d8fbe94a34..6a26919c43 100644 --- a/test/celeritas/em/SeltzerBerger.test.cc +++ b/test/celeritas/em/SeltzerBerger.test.cc @@ -374,7 +374,7 @@ TEST_F(SeltzerBergerTest, basic) TEST_F(SeltzerBergerTest, stress_test) { - int const num_samples = 1e4; + int const num_samples = 10000; std::vector avg_engine_samples; // Views diff --git a/test/celeritas/em/UrbanMsc.test.cc b/test/celeritas/em/UrbanMsc.test.cc index 052ae00153..2143c950cf 100644 --- a/test/celeritas/em/UrbanMsc.test.cc +++ b/test/celeritas/em/UrbanMsc.test.cc @@ -559,6 +559,8 @@ TEST_F(UrbanMscTest, TEST_IF_CELERITAS_DOUBLE(step_limit)) } } +constexpr double step_is_range = -1; + TEST_F(UrbanMscTest, TEST_IF_CELERITAS_DOUBLE(msc_scattering)) { // Test energies @@ -575,7 +577,6 @@ TEST_F(UrbanMscTest, TEST_IF_CELERITAS_DOUBLE(msc_scattering)) // Calculate range instead of hardcoding to ensure step and range values // are bit-for-bit identical when range limits the step. The first three // steps are not limited by range - constexpr double step_is_range = -1; std::vector step = {0.00279169, 0.412343, 0.0376414}; // [cm] step.resize(nsamples, step_is_range); diff --git a/test/celeritas/geo/HeuristicGeoTestBase.cc b/test/celeritas/geo/HeuristicGeoTestBase.cc index 666400871c..c13e1e0228 100644 --- a/test/celeritas/geo/HeuristicGeoTestBase.cc +++ b/test/celeritas/geo/HeuristicGeoTestBase.cc @@ -56,7 +56,8 @@ void HeuristicGeoTestBase::run_host(size_type num_states, real_type tolerance) ADD_FAILURE() << "Implement the following as " "TestCase::reference_avg_path() const"; - int precision_digits = std::ceil(-std::log10(tolerance) + 0.5); + int precision_digits + = static_cast(std::ceil(-std::log10(tolerance) + 0.5)); std::cout << "/* REFERENCE PATH LENGTHS */\n" "static real_type const paths[] = {" diff --git a/test/celeritas/grid/GenericGridInserter.test.cc b/test/celeritas/grid/GenericGridInserter.test.cc index bb6011bbd9..1293b40eba 100644 --- a/test/celeritas/grid/GenericGridInserter.test.cc +++ b/test/celeritas/grid/GenericGridInserter.test.cc @@ -7,6 +7,8 @@ //---------------------------------------------------------------------------// #include "celeritas/grid/GenericGridInserter.hh" +#include + #include "corecel/OpaqueId.hh" #include "celeritas/random/distribution/UniformRealDistribution.hh" @@ -17,21 +19,12 @@ namespace celeritas { namespace test { - -/* - * Dummy opaque id tag to make sure GenericGridInserter doesn't rely on a - * specific type. - */ -struct GenericIndexTag -{ -}; - //---------------------------------------------------------------------------// class GenericGridInserterTest : public ::celeritas::test::Test { protected: - using GridIndexType = OpaqueId; + using GridIndexType = OpaqueId; using RandomEngine = DiagnosticRngEngine; void SetUp() override { rng_.reset_count(); } diff --git a/test/celeritas/optical/Cerenkov.test.cc b/test/celeritas/optical/Cerenkov.test.cc index 379d603c43..7810b2debb 100644 --- a/test/celeritas/optical/Cerenkov.test.cc +++ b/test/celeritas/optical/Cerenkov.test.cc @@ -367,7 +367,7 @@ TEST_F(CerenkovTest, TEST_IF_CELERITAS_DOUBLE(generator)) real_type costheta = dot_product(inc_dir, photon.direction); avg_costheta += costheta; // Remap from [-1,1] to [0,1] - int bin = (1 + costheta) / 2 * num_bins; + int bin = static_cast((1 + costheta) / 2 * num_bins); CELER_ASSERT(bin < num_bins); ++costheta_dist[bin]; } @@ -375,7 +375,7 @@ TEST_F(CerenkovTest, TEST_IF_CELERITAS_DOUBLE(generator)) { real_type energy = photon.energy.value(); avg_energy += energy; - int bin = (energy - emin) / edel; + int bin = static_cast((energy - emin) / edel); CELER_ASSERT(bin < num_bins); ++energy_dist[bin]; } @@ -384,7 +384,7 @@ TEST_F(CerenkovTest, TEST_IF_CELERITAS_DOUBLE(generator)) real_type displacement = distance(pre_step.pos, photon.position); avg_displacement += displacement; - int bin = (displacement - dmin) / ddel; + int bin = static_cast((displacement - dmin) / ddel); CELER_ASSERT(bin < num_bins); ++displacement_dist[bin]; } diff --git a/test/celeritas/random/RngEngine.test.cc b/test/celeritas/random/RngEngine.test.cc index 95e40bac52..8e537ab8f7 100644 --- a/test/celeritas/random/RngEngine.test.cc +++ b/test/celeritas/random/RngEngine.test.cc @@ -36,8 +36,8 @@ class SequenceEngineTest : public Test public: void SetUp() override { - double const inv_32 = std::ldexp(1.0, -32.0); - double const inv_64 = std::ldexp(1.0, -64.0); + double const inv_32 = std::ldexp(1.0, -32); + double const inv_64 = std::ldexp(1.0, -64); /*! * Note: even the lowest *normalized* float value (1e-38) is below * 2**-64, so the "min" values for both double and float are diff --git a/test/celeritas/random/SequenceEngine.hh b/test/celeritas/random/SequenceEngine.hh index f9079307c4..e4fa12d2eb 100644 --- a/test/celeritas/random/SequenceEngine.hh +++ b/test/celeritas/random/SequenceEngine.hh @@ -121,7 +121,7 @@ SequenceEngine SequenceEngine::from_reals(Span values) CELER_EXPECT(v >= 0 && v < 1); // Calculate first (big end) value v *= range; - result_type second = std::floor(v); + auto second = static_cast(std::floor(v)); // Calculate second (little end) value v -= second; @@ -197,7 +197,7 @@ T GenerateCanonical::operator()( // Range for sequence engine should be [0, 2^32 - 1) = 2^32 real_type const range = static_cast(test::SequenceEngine::max()) + real_type(1); - real_type result = rng(); + real_type result = static_cast(rng()); result += rng() * range; result *= 1 / ipow<2>(range); if (CELER_UNLIKELY(result == real_type(1))) diff --git a/test/corecel/cont/Range.test.cc b/test/corecel/cont/Range.test.cc index 1c68f79e31..e63ab5472d 100644 --- a/test/corecel/cont/Range.test.cc +++ b/test/corecel/cont/Range.test.cc @@ -418,7 +418,7 @@ TEST(TEST_IF_CELER_DEVICE(DeviceRangeTest), grid_stride) input.num_threads = device().threads_per_warp(); // Calculate saxpy using CPU - std::vector z_cpu(N, 0.0); + std::vector z_cpu(N, 0); for (auto i : range(N)) { z_cpu[i] = input.a * input.x[i] + input.y[i]; diff --git a/test/corecel/math/Algorithms.test.cc b/test/corecel/math/Algorithms.test.cc index de6184758b..ea3b54c150 100644 --- a/test/corecel/math/Algorithms.test.cc +++ b/test/corecel/math/Algorithms.test.cc @@ -389,7 +389,7 @@ TEST(MathTest, diffsq) EXPECT_DOUBLE_EQ(9.0, diffsq(5.0, 4.0)); EXPECT_DOUBLE_EQ(ipow<2>(std::sin(0.2)), diffsq(1.0, std::cos(0.2))); - float a{10000.001}, b{10000}, actual{20}; + float a{10000.001f}, b{10000.f}, actual{20.f}; EXPECT_FLOAT_EQ(0.46875f, actual - diffsq(a, b)); EXPECT_LE(actual - diffsq(a, b), actual - (a * a - b * b)); } diff --git a/test/corecel/math/SoftEqual.test.cc b/test/corecel/math/SoftEqual.test.cc index 933c9dd20e..739305c23a 100644 --- a/test/corecel/math/SoftEqual.test.cc +++ b/test/corecel/math/SoftEqual.test.cc @@ -58,6 +58,7 @@ TYPED_TEST_SUITE(FloatingTest, FloatTypes, ); TYPED_TEST(FloatingTest, soft_equal) { using value_type = typename TestFixture::value_type; + using R = value_type; using Limits_t = typename TestFixture::Limits_t; using Comp = SoftEqual; @@ -73,11 +74,11 @@ TYPED_TEST(FloatingTest, soft_equal) EXPECT_TRUE(comp(1, 1 + comp.rel() / 2)); EXPECT_FALSE(comp(1, 1 + comp.rel() * 2)); // Large scale - EXPECT_TRUE(comp(1e6, 1e6 * (1 + comp.rel() / 2))); - EXPECT_FALSE(comp(1e6, 1e6 * (1 + comp.rel() * 2))); + EXPECT_TRUE(comp(R(1e6), R(1e6) * (1 + comp.rel() / 2))); + EXPECT_FALSE(comp(R(1e6), R(1e6) * (1 + comp.rel() * 2))); // Smaller scale - EXPECT_TRUE(comp(1e-5, 1e-5 * (1 + comp.rel() / 2))); - EXPECT_FALSE(comp(1e-5, 1e-6)); + EXPECT_TRUE(comp(R(1e-5), R(1e-5) * (1 + comp.rel() / 2))); + EXPECT_FALSE(comp(R(1e-5), R(1e-6))); if (std::is_same_v) { @@ -121,13 +122,15 @@ TYPED_TEST(FloatingTest, equal_or_soft_equal) using Limits_t = typename TestFixture::Limits_t; value_type const nan = Limits_t::quiet_NaN(); value_type const inf = Limits_t::infinity(); + value_type const one{1}; + value_type const zero{0}; EqualOr> comp; - EXPECT_TRUE(comp(1, 1)); - EXPECT_TRUE(comp(0, 0)); - EXPECT_FALSE(comp(-1, 1)); - EXPECT_FALSE(comp(1, -1)); + EXPECT_TRUE(comp(one, one)); + EXPECT_TRUE(comp(zero, zero)); + EXPECT_FALSE(comp(-one, one)); + EXPECT_FALSE(comp(one, -one)); EXPECT_FALSE(comp(inf, -inf)); EXPECT_FALSE(comp(-inf, inf)); @@ -135,7 +138,7 @@ TYPED_TEST(FloatingTest, equal_or_soft_equal) EXPECT_TRUE(comp(1e6, 1e6 * (1 + comp.rel() / 2))); EXPECT_FALSE(comp(1e6, 1e6 * (1 + comp.rel() * 2))); - EXPECT_FALSE(comp(1, nan)); + EXPECT_FALSE(comp(one, nan)); } TYPED_TEST(FloatingTest, soft_zero) diff --git a/test/geocel/MockGeoTrackView.hh b/test/geocel/MockGeoTrackView.hh index 11469dec4f..7fab178d66 100644 --- a/test/geocel/MockGeoTrackView.hh +++ b/test/geocel/MockGeoTrackView.hh @@ -99,7 +99,7 @@ MockGeoTrackView::operator=(Initializer_t const& init) { ++init_count_; this->state_ = init; - volume_id_ = std::floor(this->z()); + volume_id_ = static_cast(std::floor(this->z())); on_boundary_ = false; return *this; } diff --git a/test/orange/detail/BIHBuilder.test.cc b/test/orange/detail/BIHBuilder.test.cc index dbe3120780..69f1dd05c9 100644 --- a/test/orange/detail/BIHBuilder.test.cc +++ b/test/orange/detail/BIHBuilder.test.cc @@ -71,11 +71,12 @@ class BIHBuilderTest : public ::celeritas::test::Test TEST_F(BIHBuilderTest, basic) { using Edge = BIHInnerNode::Edge; + using Real3 = FastBBox::Real3; bboxes_.push_back(FastBBox::from_infinite()); - bboxes_.push_back({{0, 0, 0}, {1.6, 1, 100}}); - bboxes_.push_back({{1.2, 0, 0}, {2.8, 1, 100}}); - bboxes_.push_back({{2.8, 0, 0}, {5, 1, 100}}); + bboxes_.push_back({{0, 0, 0}, {1.6f, 1, 100}}); + bboxes_.push_back({{1.2f, 0, 0}, {2.8f, 1, 100}}); + bboxes_.push_back({{2.8f, 0, 0}, {5, 1, 100}}); bboxes_.push_back({{0, -1, 0}, {5, 0, 100}}); bboxes_.push_back({{0, -1, 0}, {5, 0, 100}}); @@ -87,8 +88,8 @@ TEST_F(BIHBuilderTest, basic) // Test bounding box storage auto bbox1 = storage_.bboxes[bih_tree.bboxes[LocalVolumeId{2}]]; - EXPECT_VEC_SOFT_EQ(Real3({1.2, 0., 0.}), bbox1.lower()); - EXPECT_VEC_SOFT_EQ(Real3({2.8, 1., 100.}), bbox1.upper()); + EXPECT_VEC_SOFT_EQ(Real3({1.2f, 0, 0}), bbox1.lower()); + EXPECT_VEC_SOFT_EQ(Real3({2.8f, 1, 100}), bbox1.upper()); // Test nodes auto inner_nodes = bih_tree.inner_nodes; @@ -102,8 +103,8 @@ TEST_F(BIHBuilderTest, basic) ASSERT_FALSE(node.parent); EXPECT_EQ(Axis{0}, node.axis); EXPECT_EQ(Axis{0}, node.axis); - EXPECT_SOFT_EQ(2.8, node.bounding_planes[Edge::left].position); - EXPECT_SOFT_EQ(0, node.bounding_planes[Edge::right].position); + EXPECT_SOFT_EQ(2.8f, node.bounding_planes[Edge::left].position); + EXPECT_SOFT_EQ(0.0f, node.bounding_planes[Edge::right].position); EXPECT_EQ(BIHNodeId{1}, node.bounding_planes[Edge::left].child); EXPECT_EQ(BIHNodeId{2}, node.bounding_planes[Edge::right].child); } @@ -114,8 +115,8 @@ TEST_F(BIHBuilderTest, basic) ASSERT_EQ(BIHNodeId{0}, node.parent); EXPECT_EQ(Axis{0}, node.axis); EXPECT_EQ(Axis{0}, node.axis); - EXPECT_SOFT_EQ(1.6, node.bounding_planes[Edge::left].position); - EXPECT_SOFT_EQ(1.2, node.bounding_planes[Edge::right].position); + EXPECT_SOFT_EQ(1.6f, node.bounding_planes[Edge::left].position); + EXPECT_SOFT_EQ(1.2f, node.bounding_planes[Edge::right].position); EXPECT_EQ(BIHNodeId{3}, node.bounding_planes[Edge::left].child); EXPECT_EQ(BIHNodeId{4}, node.bounding_planes[Edge::right].child); } @@ -126,8 +127,8 @@ TEST_F(BIHBuilderTest, basic) ASSERT_EQ(BIHNodeId{0}, node.parent); EXPECT_EQ(Axis{0}, node.axis); EXPECT_EQ(Axis{0}, node.axis); - EXPECT_SOFT_EQ(5, node.bounding_planes[Edge::left].position); - EXPECT_SOFT_EQ(2.8, node.bounding_planes[Edge::right].position); + EXPECT_SOFT_EQ(5.0f, node.bounding_planes[Edge::left].position); + EXPECT_SOFT_EQ(2.8f, node.bounding_planes[Edge::right].position); EXPECT_EQ(BIHNodeId{5}, node.bounding_planes[Edge::left].child); EXPECT_EQ(BIHNodeId{6}, node.bounding_planes[Edge::right].child); } @@ -251,8 +252,8 @@ TEST_F(BIHBuilderTest, grid) ASSERT_FALSE(node.parent); EXPECT_EQ(Axis{1}, node.axis); EXPECT_EQ(Axis{1}, node.axis); - EXPECT_SOFT_EQ(2, node.bounding_planes[Edge::left].position); - EXPECT_SOFT_EQ(2, node.bounding_planes[Edge::right].position); + EXPECT_SOFT_EQ(2.f, node.bounding_planes[Edge::left].position); + EXPECT_SOFT_EQ(2.f, node.bounding_planes[Edge::right].position); EXPECT_EQ(BIHNodeId{1}, node.bounding_planes[Edge::left].child); EXPECT_EQ(BIHNodeId{6}, node.bounding_planes[Edge::right].child); } @@ -263,8 +264,8 @@ TEST_F(BIHBuilderTest, grid) ASSERT_EQ(BIHNodeId{0}, node.parent); EXPECT_EQ(Axis{0}, node.axis); EXPECT_EQ(Axis{0}, node.axis); - EXPECT_SOFT_EQ(1, node.bounding_planes[Edge::left].position); - EXPECT_SOFT_EQ(1, node.bounding_planes[Edge::right].position); + EXPECT_SOFT_EQ(1.f, node.bounding_planes[Edge::left].position); + EXPECT_SOFT_EQ(1.f, node.bounding_planes[Edge::right].position); EXPECT_EQ(BIHNodeId{2}, node.bounding_planes[Edge::left].child); EXPECT_EQ(BIHNodeId{3}, node.bounding_planes[Edge::right].child); } @@ -275,8 +276,8 @@ TEST_F(BIHBuilderTest, grid) ASSERT_EQ(BIHNodeId{1}, node.parent); EXPECT_EQ(Axis{1}, node.axis); EXPECT_EQ(Axis{1}, node.axis); - EXPECT_SOFT_EQ(1, node.bounding_planes[Edge::left].position); - EXPECT_SOFT_EQ(1, node.bounding_planes[Edge::right].position); + EXPECT_SOFT_EQ(1.f, node.bounding_planes[Edge::left].position); + EXPECT_SOFT_EQ(1.f, node.bounding_planes[Edge::right].position); EXPECT_EQ(BIHNodeId{11}, node.bounding_planes[Edge::left].child); EXPECT_EQ(BIHNodeId{12}, node.bounding_planes[Edge::right].child); } @@ -287,8 +288,8 @@ TEST_F(BIHBuilderTest, grid) ASSERT_EQ(BIHNodeId{1}, node.parent); EXPECT_EQ(Axis{0}, node.axis); EXPECT_EQ(Axis{0}, node.axis); - EXPECT_SOFT_EQ(2, node.bounding_planes[Edge::left].position); - EXPECT_SOFT_EQ(2, node.bounding_planes[Edge::right].position); + EXPECT_SOFT_EQ(2.f, node.bounding_planes[Edge::left].position); + EXPECT_SOFT_EQ(2.f, node.bounding_planes[Edge::right].position); EXPECT_EQ(BIHNodeId{4}, node.bounding_planes[Edge::left].child); EXPECT_EQ(BIHNodeId{5}, node.bounding_planes[Edge::right].child); } @@ -299,8 +300,8 @@ TEST_F(BIHBuilderTest, grid) ASSERT_EQ(BIHNodeId{3}, node.parent); EXPECT_EQ(Axis{1}, node.axis); EXPECT_EQ(Axis{1}, node.axis); - EXPECT_SOFT_EQ(1, node.bounding_planes[Edge::left].position); - EXPECT_SOFT_EQ(1, node.bounding_planes[Edge::right].position); + EXPECT_SOFT_EQ(1.f, node.bounding_planes[Edge::left].position); + EXPECT_SOFT_EQ(1.f, node.bounding_planes[Edge::right].position); EXPECT_EQ(BIHNodeId{13}, node.bounding_planes[Edge::left].child); EXPECT_EQ(BIHNodeId{14}, node.bounding_planes[Edge::right].child); } @@ -311,8 +312,8 @@ TEST_F(BIHBuilderTest, grid) ASSERT_EQ(BIHNodeId{3}, node.parent); EXPECT_EQ(Axis{1}, node.axis); EXPECT_EQ(Axis{1}, node.axis); - EXPECT_SOFT_EQ(1, node.bounding_planes[Edge::left].position); - EXPECT_SOFT_EQ(1, node.bounding_planes[Edge::right].position); + EXPECT_SOFT_EQ(1.f, node.bounding_planes[Edge::left].position); + EXPECT_SOFT_EQ(1.f, node.bounding_planes[Edge::right].position); EXPECT_EQ(BIHNodeId{15}, node.bounding_planes[Edge::left].child); EXPECT_EQ(BIHNodeId{16}, node.bounding_planes[Edge::right].child); } diff --git a/test/orange/detail/BIHTraverser.test.cc b/test/orange/detail/BIHTraverser.test.cc index c692640a85..a7e4573d96 100644 --- a/test/orange/detail/BIHTraverser.test.cc +++ b/test/orange/detail/BIHTraverser.test.cc @@ -66,9 +66,9 @@ class BIHTraverserTest : public Test TEST_F(BIHTraverserTest, basic) { bboxes_.push_back(FastBBox::from_infinite()); - bboxes_.push_back({{0, 0, 0}, {1.6, 1, 100}}); - bboxes_.push_back({{1.2, 0, 0}, {2.8, 1, 100}}); - bboxes_.push_back({{2.8, 0, 0}, {5, 1, 100}}); + bboxes_.push_back({{0, 0, 0}, {1.6f, 1, 100}}); + bboxes_.push_back({{1.2f, 0, 0}, {2.8f, 1, 100}}); + bboxes_.push_back({{2.8f, 0, 0}, {5, 1, 100}}); bboxes_.push_back({{0, -1, 0}, {5, 0, 100}}); bboxes_.push_back({{0, -1, 0}, {5, 0, 100}}); @@ -76,14 +76,14 @@ TEST_F(BIHTraverserTest, basic) auto bih_tree = bih(std::move(bboxes_)); ref_storage_ = storage_; - BIHTraverser traverser(bih_tree, ref_storage_); - - EXPECT_EQ(LocalVolumeId{0}, traverser({0.8, 0.5, 110}, valid_volid_)); - EXPECT_EQ(LocalVolumeId{1}, traverser({0.8, 0.5, 30}, valid_volid_)); - EXPECT_EQ(LocalVolumeId{2}, traverser({2.0, 0.6, 40}, valid_volid_)); - EXPECT_EQ(LocalVolumeId{3}, traverser({2.9, 0.7, 50}, valid_volid_)); - EXPECT_EQ(LocalVolumeId{4}, traverser({2.9, -0.7, 50}, valid_volid_)); - EXPECT_EQ(LocalVolumeId{5}, traverser({2.9, -0.7, 50}, odd_volid_)); + BIHTraverser traverse(bih_tree, ref_storage_); + + EXPECT_EQ(LocalVolumeId{0}, traverse({0.8, 0.5, 110}, valid_volid_)); + EXPECT_EQ(LocalVolumeId{1}, traverse({0.8, 0.5, 30}, valid_volid_)); + EXPECT_EQ(LocalVolumeId{2}, traverse({2.0, 0.6, 40}, valid_volid_)); + EXPECT_EQ(LocalVolumeId{3}, traverse({2.9, 0.7, 50}, valid_volid_)); + EXPECT_EQ(LocalVolumeId{4}, traverse({2.9, -0.7, 50}, valid_volid_)); + EXPECT_EQ(LocalVolumeId{5}, traverse({2.9, -0.7, 50}, odd_volid_)); } //---------------------------------------------------------------------------// @@ -118,9 +118,9 @@ TEST_F(BIHTraverserTest, grid) auto bih_tree = bih(std::move(bboxes_)); ref_storage_ = storage_; - BIHTraverser traverser(bih_tree, ref_storage_); + BIHTraverser traverse(bih_tree, ref_storage_); - EXPECT_EQ(LocalVolumeId{0}, traverser({0.8, 0.5, 110}, valid_volid_)); + EXPECT_EQ(LocalVolumeId{0}, traverse({0.8, 0.5, 110}, valid_volid_)); size_type index{1}; for (auto i : range(3)) @@ -129,7 +129,7 @@ TEST_F(BIHTraverserTest, grid) { constexpr real_type half{0.5}; EXPECT_EQ(LocalVolumeId{index++}, - traverser({half + i, half + j, 30}, valid_volid_)); + traverse({half + i, half + j, 30}, valid_volid_)); } } } @@ -146,9 +146,9 @@ TEST_F(BIHTraverserTest, single_finite_volume) auto bih_tree = bih(std::move(bboxes_)); ref_storage_ = storage_; - BIHTraverser traverser(bih_tree, ref_storage_); + BIHTraverser traverse(bih_tree, ref_storage_); - EXPECT_EQ(LocalVolumeId{0}, traverser({0.5, 0.5, 0.5}, valid_volid_)); + EXPECT_EQ(LocalVolumeId{0}, traverse({0.5, 0.5, 0.5}, valid_volid_)); } TEST_F(BIHTraverserTest, multiple_nonpartitionable_volumes) @@ -160,10 +160,10 @@ TEST_F(BIHTraverserTest, multiple_nonpartitionable_volumes) auto bih_tree = bih(std::move(bboxes_)); ref_storage_ = storage_; - BIHTraverser traverser(bih_tree, ref_storage_); + BIHTraverser traverse(bih_tree, ref_storage_); - EXPECT_EQ(LocalVolumeId{0}, traverser({0.5, 0.5, 0.5}, valid_volid_)); - EXPECT_EQ(LocalVolumeId{1}, traverser({0.5, 0.5, 0.5}, odd_volid_)); + EXPECT_EQ(LocalVolumeId{0}, traverse({0.5, 0.5, 0.5}, valid_volid_)); + EXPECT_EQ(LocalVolumeId{1}, traverse({0.5, 0.5, 0.5}, odd_volid_)); } TEST_F(BIHTraverserTest, single_infinite_volume) @@ -174,9 +174,9 @@ TEST_F(BIHTraverserTest, single_infinite_volume) auto bih_tree = bih(std::move(bboxes_)); ref_storage_ = storage_; - BIHTraverser traverser(bih_tree, ref_storage_); + BIHTraverser traverse(bih_tree, ref_storage_); - EXPECT_EQ(LocalVolumeId{0}, traverser({0.5, 0.5, 0.5}, valid_volid_)); + EXPECT_EQ(LocalVolumeId{0}, traverse({0.5, 0.5, 0.5}, valid_volid_)); } TEST_F(BIHTraverserTest, multiple_infinite_volumes) @@ -188,10 +188,10 @@ TEST_F(BIHTraverserTest, multiple_infinite_volumes) auto bih_tree = bih(std::move(bboxes_)); ref_storage_ = storage_; - BIHTraverser traverser(bih_tree, ref_storage_); + BIHTraverser traverse(bih_tree, ref_storage_); - EXPECT_EQ(LocalVolumeId{0}, traverser({0.5, 0.5, 0.5}, valid_volid_)); - EXPECT_EQ(LocalVolumeId{1}, traverser({0.5, 0.5, 0.5}, odd_volid_)); + EXPECT_EQ(LocalVolumeId{0}, traverse({0.5, 0.5, 0.5}, valid_volid_)); + EXPECT_EQ(LocalVolumeId{1}, traverse({0.5, 0.5, 0.5}, odd_volid_)); } //---------------------------------------------------------------------------// diff --git a/test/orange/orangeinp/CsgTree.test.cc b/test/orange/orangeinp/CsgTree.test.cc index ac505d9380..3dc889834f 100644 --- a/test/orange/orangeinp/CsgTree.test.cc +++ b/test/orange/orangeinp/CsgTree.test.cc @@ -22,6 +22,12 @@ namespace test //---------------------------------------------------------------------------// TEST(CsgTypes, hash) { +#ifdef _MSC_VER + // TODO: if performance on windows is negatively affected, fix this + GTEST_SKIP() + << "in MSVC, std::variant hash does *not* change based on the " + "type index"; +#endif std::hash variant_hash; EXPECT_NE(variant_hash(True{}), variant_hash(False{})); EXPECT_NE(variant_hash(Aliased{N{0}}), variant_hash(Surface{S{0}})); diff --git a/test/testdetail/TestMacrosImpl.hh b/test/testdetail/TestMacrosImpl.hh index bf6c9d346a..cc20af6b1d 100644 --- a/test/testdetail/TestMacrosImpl.hh +++ b/test/testdetail/TestMacrosImpl.hh @@ -135,8 +135,11 @@ template using ValueT = typename SoftPrecisionType::type; using BinaryOp = EqualOr>; - return IsSoftEquivImpl( - expected, expected_expr, actual, actual_expr, BinaryOp{}); + return IsSoftEquivImpl(static_cast(expected), + expected_expr, + static_cast(actual), + actual_expr, + BinaryOp{}); } //---------------------------------------------------------------------------//