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>
20#include "gtest/gtest.h"
21
22TEST(TestOpalSplineTimeDependence, ConstructorTest) {
24 const OpalSplineTimeDependence* dep_clone = dep.clone("new name");
25 EXPECT_EQ(dep_clone->getOpalName(), "new name");
26}
27
28TEST(TestOpalSplineTimeDependence, PrintTest) {
30 std::stringstream _string;
31 dep.print(_string);
32 EXPECT_EQ(_string.str(), "SPLINE_TIME_DEPENDENCE;\n");
33}
34
35TEST(TestOpalSplineTimeDependence, UserInterface) {
36 // Make the UI
38 // Set the attributes
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
53TEST(TestOpalSplineTimeDependence, DefaultValues) {
54 // Make the UI
56 // Set the attributes
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
69TEST(TestOpalSplineTimeDependence, UserInterfaceBadOrder) {
70 // Make the UI
72 // Set the attributes
76 // Update the object
77 EXPECT_ANY_THROW(ui.update());
78}
TEST(TestOpalSplineTimeDependence, ConstructorTest)
static std::shared_ptr< AbstractTimeDependence > getTimeDependence(const std::string &name)
const std::string & getOpalName() const
Return object name.
Definition Object.cpp:267
std::vector< Attribute > itsAttr
The object attributes.
Definition Object.h:210
OpalSplineTimeDependence * clone(const std::string &name) override
void print(std::ostream &) const override
void setRealArray(Attribute &attr, const std::vector< double > &value)
Set array value.
void setReal(Attribute &attr, double val)
Set real value.