libMesh
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ParametersTest Class Reference
Inheritance diagram for ParametersTest:
[legend]

Public Member Functions

 LIBMESH_CPPUNIT_TEST_SUITE (ParametersTest)
 
 CPPUNIT_TEST (testInt)
 
 CPPUNIT_TEST (testFloat)
 
 CPPUNIT_TEST (testDouble)
 
 CPPUNIT_TEST (testMap)
 
 CPPUNIT_TEST_SUITE_END ()
 
void setUp ()
 
void tearDown ()
 
template<typename T >
void testScalar ()
 
void testMap ()
 
void testInt ()
 
void testFloat ()
 
void testDouble ()
 

Detailed Description

Definition at line 10 of file parameters_test.C.

Member Function Documentation

◆ CPPUNIT_TEST() [1/4]

ParametersTest::CPPUNIT_TEST ( testDouble  )

◆ CPPUNIT_TEST() [2/4]

ParametersTest::CPPUNIT_TEST ( testFloat  )

◆ CPPUNIT_TEST() [3/4]

ParametersTest::CPPUNIT_TEST ( testInt  )

◆ CPPUNIT_TEST() [4/4]

ParametersTest::CPPUNIT_TEST ( testMap  )

◆ CPPUNIT_TEST_SUITE_END()

ParametersTest::CPPUNIT_TEST_SUITE_END ( )

◆ LIBMESH_CPPUNIT_TEST_SUITE()

ParametersTest::LIBMESH_CPPUNIT_TEST_SUITE ( ParametersTest  )

◆ setUp()

void ParametersTest::setUp ( )
inline

Definition at line 25 of file parameters_test.C.

26 {}

◆ tearDown()

void ParametersTest::tearDown ( )
inline

Definition at line 28 of file parameters_test.C.

29 {}

◆ testDouble()

void ParametersTest::testDouble ( )
inline

Definition at line 69 of file parameters_test.C.

69{ LOG_UNIT_TEST; testScalar<double>(); }

◆ testFloat()

void ParametersTest::testFloat ( )
inline

Definition at line 68 of file parameters_test.C.

68{ LOG_UNIT_TEST; testScalar<float>(); }

◆ testInt()

void ParametersTest::testInt ( )
inline

Definition at line 67 of file parameters_test.C.

67{ LOG_UNIT_TEST; testScalar<int>(); }

◆ testMap()

void ParametersTest::testMap ( )
inline

Definition at line 49 of file parameters_test.C.

50 {
51 LOG_UNIT_TEST;
52
53 Parameters param;
54
55 std::map<int, std::string> m;
56 m[2] = "two";
57 m[4] = "four";
58 param.set<std::map<int, std::string>>("mymap") = m;
59 const std::map<int, std::string> & gotten =
60 param.get<std::map<int, std::string>>("mymap");
61
62 CPPUNIT_ASSERT_EQUAL(gotten.size(), std::size_t(2));
63 CPPUNIT_ASSERT_EQUAL(gotten.at(2), std::string("two"));
64 CPPUNIT_ASSERT_EQUAL(gotten.at(4), std::string("four"));
65 }
This class provides the ability to map between arbitrary, user-defined strings and several data types...
Definition parameters.h:75
T & set(const std::string &)
Definition parameters.h:494
const T & get(std::string_view) const
Definition parameters.h:451

References libMesh::Parameters::get(), and libMesh::Parameters::set().

◆ testScalar()

template<typename T >
void ParametersTest::testScalar ( )
inline

Definition at line 32 of file parameters_test.C.

33 {
34 [[maybe_unused]] // nvc++ has some issues...
35 Parameters param;
36
37 T t = 10, t_orig = 10;
38
39 param.set<T>("first") = t;
40
41 ++t;
42
43 param.set<T>("second") = t;
44
45 CPPUNIT_ASSERT_EQUAL(t_orig, param.get<T>("first"));
46 CPPUNIT_ASSERT_EQUAL(t, param.get<T>("second"));
47 }

References libMesh::Parameters::get(), and libMesh::Parameters::set().


The documentation for this class was generated from the following file: