Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-03-28 07:46:29

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/unit_test.hpp>
0010 
0011 #include "Acts/Geometry/GeometryContext.hpp"
0012 
0013 using namespace Acts;
0014 
0015 BOOST_AUTO_TEST_SUITE(GeometryContextTests)
0016 
0017 BOOST_AUTO_TEST_CASE(DangerouslyDefaultConstruct) {
0018   auto ctx = GeometryContext::dangerouslyDefaultConstruct();
0019   BOOST_CHECK(!ctx.hasValue());
0020 }
0021 
0022 BOOST_AUTO_TEST_CASE(FactoryCreatesEmptyContext) {
0023   auto ctx1 = GeometryContext::dangerouslyDefaultConstruct();
0024   auto ctx2 = GeometryContext::dangerouslyDefaultConstruct();
0025 
0026   // Both should be empty
0027   BOOST_CHECK(!ctx1.hasValue());
0028   BOOST_CHECK(!ctx2.hasValue());
0029 }
0030 
0031 BOOST_AUTO_TEST_CASE(ExplicitConstructionWithValue) {
0032   struct TestContext {
0033     int value = 42;
0034   };
0035 
0036   GeometryContext ctx{TestContext{}};
0037   BOOST_CHECK(ctx.hasValue());
0038   BOOST_CHECK_EQUAL(ctx.get<TestContext>().value, 42);
0039 }
0040 
0041 BOOST_AUTO_TEST_CASE(TemplateConstructorMoveSemantics) {
0042   struct Movable {
0043     int value;
0044     explicit Movable(int v) : value(v) {}
0045     Movable(const Movable&) = default;
0046     Movable(Movable&&) = default;
0047   };
0048 
0049   GeometryContext ctx{Movable{99}};
0050   BOOST_CHECK_EQUAL(ctx.get<Movable>().value, 99);
0051 }
0052 
0053 BOOST_AUTO_TEST_CASE(TemplateConstructorCopySemantics) {
0054   struct TestContext {
0055     int value = 123;
0056   };
0057   TestContext tc;
0058 
0059   GeometryContext ctx{tc};
0060   BOOST_CHECK_EQUAL(ctx.get<TestContext>().value, 123);
0061 }
0062 
0063 BOOST_AUTO_TEST_CASE(AssignmentOperatorWorks) {
0064   auto ctx = GeometryContext::dangerouslyDefaultConstruct();
0065   struct TestContext {
0066     double value = 3.14;
0067   };
0068 
0069   ctx = TestContext{};
0070   BOOST_CHECK(ctx.hasValue());
0071   BOOST_CHECK_EQUAL(ctx.get<TestContext>().value, 3.14);
0072 }
0073 
0074 BOOST_AUTO_TEST_SUITE_END()