File indexing completed on 2025-01-18 09:12:38
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Geometry/GeometryIdentifier.hpp"
0012
0013 namespace Acts::Test {
0014
0015 BOOST_AUTO_TEST_CASE(GeometryIdentifier_construct_default) {
0016 GeometryIdentifier id;
0017 BOOST_CHECK_EQUAL(id.volume(), 0u);
0018 BOOST_CHECK_EQUAL(id.boundary(), 0u);
0019 BOOST_CHECK_EQUAL(id.layer(), 0u);
0020 BOOST_CHECK_EQUAL(id.approach(), 0u);
0021 BOOST_CHECK_EQUAL(id.sensitive(), 0u);
0022 }
0023
0024 BOOST_AUTO_TEST_CASE(GeometryIdentifier_construct_encoded) {
0025
0026
0027 GeometryIdentifier id = 0xa0b00c00d00affe0u;
0028 BOOST_CHECK_EQUAL(id.volume(), 0xa0u);
0029 BOOST_CHECK_EQUAL(id.boundary(), 0xb0u);
0030 BOOST_CHECK_EQUAL(id.layer(), 0x0c0u);
0031 BOOST_CHECK_EQUAL(id.approach(), 0x0du);
0032 BOOST_CHECK_EQUAL(id.sensitive(), 0x00affu);
0033 BOOST_CHECK_EQUAL(id.extra(), 0xe0u);
0034 }
0035
0036 BOOST_AUTO_TEST_CASE(GeometryIdentifier_max_values) {
0037
0038 constexpr GeometryIdentifier::Value volumeMax = (1u << 8) - 1;
0039 constexpr GeometryIdentifier::Value boundaryMax = (1u << 8) - 1;
0040 constexpr GeometryIdentifier::Value layerMax = (1u << 12) - 1;
0041 constexpr GeometryIdentifier::Value approachMax = (1u << 8) - 1;
0042 constexpr GeometryIdentifier::Value sensitiveMax = (1u << 20) - 1;
0043 constexpr GeometryIdentifier::Value extraMax = (1u << 8) - 1;
0044
0045 constexpr GeometryIdentifier ref = 0xdeadaffe01234567;
0046
0047
0048 BOOST_CHECK_EQUAL(GeometryIdentifier(ref).setVolume(volumeMax + 1),
0049 GeometryIdentifier(ref).setVolume(0u));
0050 BOOST_CHECK_EQUAL(GeometryIdentifier(ref).setBoundary(boundaryMax + 1),
0051 GeometryIdentifier(ref).setBoundary(0u));
0052 BOOST_CHECK_EQUAL(GeometryIdentifier(ref).setLayer(layerMax + 1),
0053 GeometryIdentifier(ref).setLayer(0u));
0054 BOOST_CHECK_EQUAL(GeometryIdentifier(ref).setApproach(approachMax + 1),
0055 GeometryIdentifier(ref).setApproach(0u));
0056 BOOST_CHECK_EQUAL(GeometryIdentifier(ref).setSensitive(sensitiveMax + 1),
0057 GeometryIdentifier(ref).setSensitive(0u));
0058 BOOST_CHECK_EQUAL(GeometryIdentifier(ref).setExtra(extraMax + 1),
0059 GeometryIdentifier(ref).setExtra(0u));
0060 }
0061
0062 BOOST_AUTO_TEST_CASE(GeometryIdentifier_order) {
0063 auto vol1 = GeometryIdentifier()
0064 .setVolume(1u)
0065 .setLayer(14u)
0066 .setSensitive(5u)
0067 .setExtra(42u);
0068 auto vol2 = GeometryIdentifier()
0069 .setVolume(2u)
0070 .setLayer(13u)
0071 .setSensitive(3u)
0072 .setExtra(43u);
0073
0074 BOOST_CHECK_LT(vol1, vol2);
0075 BOOST_CHECK_LT(GeometryIdentifier(vol1).setBoundary(64u), vol2);
0076 BOOST_CHECK_LT(GeometryIdentifier(vol1).setLayer(64u), vol2);
0077 BOOST_CHECK_LT(GeometryIdentifier(vol1).setApproach(64u), vol2);
0078 BOOST_CHECK_LT(GeometryIdentifier(vol1).setSensitive(64u), vol2);
0079 BOOST_CHECK_LT(GeometryIdentifier(vol1).setSensitive(64u), vol2);
0080 BOOST_CHECK_LT(vol2, GeometryIdentifier(vol1).setVolume(3u));
0081
0082 BOOST_CHECK_LT(GeometryIdentifier(vol1).setVolume(1u).setBoundary(2u),
0083 GeometryIdentifier(vol1).setVolume(2u).setBoundary(1u));
0084 BOOST_CHECK_LT(GeometryIdentifier(vol1).setBoundary(1u).setLayer(2u),
0085 GeometryIdentifier(vol1).setBoundary(2u).setLayer(1u));
0086 BOOST_CHECK_LT(GeometryIdentifier(vol1).setLayer(1u).setApproach(2u),
0087 GeometryIdentifier(vol1).setLayer(2u).setApproach(1u));
0088 BOOST_CHECK_LT(GeometryIdentifier(vol1).setApproach(1u).setSensitive(2u),
0089 GeometryIdentifier(vol1).setApproach(2u).setSensitive(1u));
0090 BOOST_CHECK_LT(GeometryIdentifier(vol1).setSensitive(1u).setExtra(2u),
0091 GeometryIdentifier(vol1).setSensitive(2u).setExtra(1u));
0092 }
0093
0094 }