preCICE v3.1.1
Loading...
Searching...
No Matches
XMLTest.cpp
Go to the documentation of this file.
1#include <Eigen/Core>
2#include <string>
3#include <tuple>
4#include "math/constants.hpp"
6#include "testing/Testing.hpp"
7#include "xml/ValueParser.hpp"
9#include "xml/XMLTag.hpp"
10
11using namespace precice;
12using namespace precice::xml;
14
16
18 Eigen::VectorXd eigenVectorXd;
19
21 {
22 if (callingTag.getName() == "test-eigen-vectorxd-attributes") {
23 eigenVectorXd = callingTag.getEigenVectorXdAttributeValue("value", 3);
24 }
25 }
26
28 {
29 std::ignore = callingTag;
30 }
31};
32
34{
35 PRECICE_TEST(1_rank);
36 std::string filename(getPathToSources() + "/xml/tests/config_xmltest_concatenation.xml");
37
39 XMLTag rootTag(cb, "configuration", XMLTag::OCCUR_ONCE);
40 XMLTag testcaseTag(cb, "test-attribute-concatenation", XMLTag::OCCUR_ONCE);
42
43 auto attr = makeXMLAttribute("attribute", "").setOptions({"value-one", "value-two", "value-three"});
44 testTag.addAttribute(attr);
45
46 testcaseTag.addSubtag(testTag);
47 rootTag.addSubtag(testcaseTag);
48
50}
51
53{
54 PRECICE_TEST(1_rank);
55 std::string filename(getPathToSources() + "/xml/tests/config_xmltest_vectorattributes.xml");
56
58 XMLTag rootTag(cb, "configuration", XMLTag::OCCUR_ONCE);
59 XMLTag testTagEigenXd(cb, "test-eigen-vectorxd-attributes", XMLTag::OCCUR_ONCE);
60
62 testTagEigenXd.addAttribute(attrEigenXd);
63 rootTag.addSubtag(testTagEigenXd);
64
66 BOOST_TEST(cb.eigenVectorXd(0) == 3.0);
67 BOOST_TEST(cb.eigenVectorXd(1) == 2.0);
68 BOOST_TEST(cb.eigenVectorXd(2) == 1.0);
69}
70
BOOST_AUTO_TEST_SUITE(PreProcess)
BOOST_AUTO_TEST_SUITE_END()
#define PRECICE_TEST(...)
Definition Testing.hpp:27
BOOST_AUTO_TEST_CASE(AttributeConcatenation)
Definition XMLTest.cpp:33
XMLAttribute & setOptions(std::vector< ATTRIBUTE_T > options)
const std::string & getName() const
Represents an XML tag to be configured automatically.
Definition XMLTag.hpp:31
std::string getPathToSources()
Returns the base path to the sources.
Definition Testing.cpp:31
contains the XML configuration parser.
XMLAttribute< std::string > makeXMLAttribute(std::string name, const char *defaultValue)
void configure(XMLTag &tag, const precice::xml::ConfigurationContext &context, std::string_view configurationFilename)
Configures the given configuration from file configurationFilename.
Definition XMLTag.cpp:395
Main namespace of the precice library.
Eigen::VectorXd eigenVectorXd
Definition XMLTest.cpp:18
void xmlEndTagCallback(const ConfigurationContext &context, XMLTag &callingTag) override
Callback at end of XML tag and at end of subtag.
Definition XMLTest.cpp:27
void xmlTagCallback(const ConfigurationContext &context, XMLTag &callingTag) override
Callback at begin of XML tag.
Definition XMLTest.cpp:20
Tightly coupled to the parameters of Participant()
Definition XMLTag.hpp:24