Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
TestConstField.cpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file TestConstField.cpp
1
#include <
gtest/gtest.h
>
2
3
#include <TVector3.h>
4
5
#include <
Exception.h
>
6
#include <
ConstField.h
>
7
#include <
FieldManager.h
>
8
9
namespace
genfit {
10
11
class
ConstFieldUninitializedTests
:
public
::testing::Test
{
12
protected
:
13
};
14
15
TEST_F
(
ConstFieldUninitializedTests
, UninitializedBehaviour) {
16
EXPECT_EQ
(
false
,
genfit::FieldManager::getInstance
()->isInitialized());
17
EXPECT_THROW
(
genfit::FieldManager::getInstance
()->getField(), std::runtime_error);
18
EXPECT_THROW
(
genfit::FieldManager::getInstance
()->checkInitialized(), std::runtime_error);
19
EXPECT_THROW
(
genfit::FieldManager::getInstance
()->getFieldVal(TVector3(1, 1, 1)), std::runtime_error);
20
}
21
22
23
class
ConstFieldInitializedTests
:
public
::testing::Test
{
24
protected
:
25
virtual
void
SetUp
() {
26
const
double
bFieldZ = 20;
// kGauss. Is 1.5T
27
m_constField
=
new
genfit::ConstField
(0., 0., bFieldZ);
28
genfit::FieldManager::getInstance
()->
init
(
m_constField
);
29
}
30
virtual
void
TearDown
() {
31
genfit::FieldManager::getInstance
()->
destruct
();
32
33
}
34
genfit::ConstField
*
m_constField
;
35
};
36
37
TEST_F
(
ConstFieldInitializedTests
, InitializedBehaviour) {
38
EXPECT_EQ
(
true
,
genfit::FieldManager::getInstance
()->isInitialized());
39
EXPECT_NO_THROW
(
genfit::FieldManager::getInstance
()->checkInstanciated());
40
EXPECT_NO_THROW
(
genfit::FieldManager::getInstance
()->checkInitialized());
41
EXPECT_EQ
(TVector3(0, 0, 20),
genfit::FieldManager::getInstance
()->getFieldVal(TVector3(1, 1, 1)));
42
}
43
44
}
GenFit
blob
master
gtest
TestConstField.cpp
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:17
using
1.8.2 with
sPHENIX GitHub integration