OPALX (Object Oriented Parallel Accelerator Library for Exascal)
master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
TestOpalSplineTimeDependence.cpp
Go to the documentation of this file.
1
//
2
// Copyright (c) 2026, Paul Scherrer Institute, Villigen PSI, Switzerland
3
// All rights reserved
4
//
5
// This file is part of OPAL.
6
//
7
// OPAL is free software: you can redistribute it and/or modify
8
// it under the terms of the GNU General Public License as published by
9
// the Free Software Foundation, either version 3 of the License, or
10
// (at your option) any later version.
11
//
12
// You should have received a copy of the GNU General License
13
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
14
//
15
16
#include <sstream>
17
#include "
Algorithms/SplineTimeDependence.h
"
18
#include "
Attributes/Attributes.h
"
19
#include "
Elements/OpalSplineTimeDependence.h
"
20
#include "gtest/gtest.h"
21
22
TEST
(TestOpalSplineTimeDependence, ConstructorTest) {
23
OpalSplineTimeDependence
dep;
24
const
OpalSplineTimeDependence
* dep_clone = dep.
clone
(
"new name"
);
25
EXPECT_EQ(dep_clone->
getOpalName
(),
"new name"
);
26
}
27
28
TEST
(TestOpalSplineTimeDependence, PrintTest) {
29
const
OpalSplineTimeDependence
dep;
30
std::stringstream _string;
31
dep.
print
(_string);
32
EXPECT_EQ(_string.str(),
"SPLINE_TIME_DEPENDENCE;\n"
);
33
}
34
35
TEST
(TestOpalSplineTimeDependence, UserInterface) {
36
// Make the UI
37
OpalSplineTimeDependence
ui;
38
// Set the attributes
39
Attributes::setReal
(ui.
itsAttr
[
OpalSplineTimeDependence::ORDER
], 3);
40
Attributes::setRealArray
(ui.
itsAttr
[
OpalSplineTimeDependence::TIMES
], {1, 2, 3, 4});
41
Attributes::setRealArray
(ui.
itsAttr
[
OpalSplineTimeDependence::VALUES
], {5, 6, 7, 8});
42
// Update the object
43
EXPECT_NO_THROW(ui.
update
());
44
// Check the values
45
auto
* myDependency =
dynamic_cast<
SplineTimeDependence
*
>
(
46
AbstractTimeDependence::getTimeDependence
(
"SPLINE_TIME_DEPENDENCE"
).get());
47
EXPECT_TRUE(myDependency);
48
EXPECT_EQ(myDependency->getSplineOrder(), 3);
49
EXPECT_EQ(myDependency->getTimes(), (std::vector{1.0, 2.0, 3.0, 4.0}));
50
EXPECT_EQ(myDependency->getValues(), (std::vector{5.0, 6.0, 7.0, 8.0}));
51
}
52
53
TEST
(TestOpalSplineTimeDependence, DefaultValues) {
54
// Make the UI
55
OpalSplineTimeDependence
ui;
56
// Set the attributes
57
Attributes::setReal
(ui.
itsAttr
[
OpalSplineTimeDependence::ORDER
], 1);
58
// Update the object
59
EXPECT_NO_THROW(ui.
update
());
60
// Check the values
61
auto
* myDependency =
dynamic_cast<
SplineTimeDependence
*
>
(
62
AbstractTimeDependence::getTimeDependence
(
"SPLINE_TIME_DEPENDENCE"
).get());
63
EXPECT_TRUE(myDependency);
64
EXPECT_EQ(myDependency->getSplineOrder(), 1);
65
EXPECT_EQ(myDependency->getTimes(), (std::vector{0.0, 1.0}));
66
EXPECT_EQ(myDependency->getValues(), (std::vector{0.0, 0.0}));
67
}
68
69
TEST
(TestOpalSplineTimeDependence, UserInterfaceBadOrder) {
70
// Make the UI
71
OpalSplineTimeDependence
ui;
72
// Set the attributes
73
Attributes::setReal
(ui.
itsAttr
[
OpalSplineTimeDependence::ORDER
], 2);
74
Attributes::setRealArray
(ui.
itsAttr
[
OpalSplineTimeDependence::TIMES
], {1, 2, 3, 4});
75
Attributes::setRealArray
(ui.
itsAttr
[
OpalSplineTimeDependence::VALUES
], {5, 6, 7, 8});
76
// Update the object
77
EXPECT_ANY_THROW(ui.
update
());
78
}
Attributes.h
OpalSplineTimeDependence.h
SplineTimeDependence.h
TEST
TEST(TestOpalSplineTimeDependence, ConstructorTest)
Definition
TestOpalSplineTimeDependence.cpp:22
AbstractTimeDependence::getTimeDependence
static std::shared_ptr< AbstractTimeDependence > getTimeDependence(const std::string &name)
Definition
AbstractTimeDependence.cpp:24
Object::getOpalName
const std::string & getOpalName() const
Return object name.
Definition
Object.cpp:267
Object::itsAttr
std::vector< Attribute > itsAttr
The object attributes.
Definition
Object.h:210
OpalSplineTimeDependence
Definition
OpalSplineTimeDependence.h:25
OpalSplineTimeDependence::clone
OpalSplineTimeDependence * clone(const std::string &name) override
Definition
OpalSplineTimeDependence.cpp:53
OpalSplineTimeDependence::print
void print(std::ostream &) const override
Definition
OpalSplineTimeDependence.cpp:57
OpalSplineTimeDependence::VALUES
@ VALUES
Definition
OpalSplineTimeDependence.h:31
OpalSplineTimeDependence::ORDER
@ ORDER
Definition
OpalSplineTimeDependence.h:29
OpalSplineTimeDependence::TIMES
@ TIMES
Definition
OpalSplineTimeDependence.h:30
OpalSplineTimeDependence::update
void update() override
Definition
OpalSplineTimeDependence.cpp:63
SplineTimeDependence
Definition
SplineTimeDependence.h:37
Attributes::setRealArray
void setRealArray(Attribute &attr, const std::vector< double > &value)
Set array value.
Definition
Attributes.cpp:297
Attributes::setReal
void setReal(Attribute &attr, double val)
Set real value.
Definition
Attributes.cpp:260
unit_tests
Elements
TestOpalSplineTimeDependence.cpp
Generated on Mon Jun 1 2026 10:40:53 for OPALX (Object Oriented Parallel Accelerator Library for Exascal) by
1.9.8