GRINS-0.7.0
List of all members | Public Member Functions | Private Member Functions
GRINSTesting::StringUtilitiesTest Class Reference
Inheritance diagram for GRINSTesting::StringUtilitiesTest:
Inheritance graph
[legend]
Collaboration diagram for GRINSTesting::StringUtilitiesTest:
Collaboration graph
[legend]

Public Member Functions

 CPPUNIT_TEST_SUITE (StringUtilitiesTest)
 
 CPPUNIT_TEST (test_split_string)
 
 CPPUNIT_TEST (test_string_to_T)
 
 CPPUNIT_TEST (test_T_to_string)
 
 CPPUNIT_TEST_SUITE_END ()
 
void test_split_string ()
 
void test_string_to_T ()
 
void test_T_to_string ()
 

Private Member Functions

void test_string (const std::vector< std::string > &test, const std::vector< std::string > &exact)
 

Detailed Description

Definition at line 41 of file string_utils.C.

Member Function Documentation

GRINSTesting::StringUtilitiesTest::CPPUNIT_TEST ( test_split_string  )
GRINSTesting::StringUtilitiesTest::CPPUNIT_TEST ( test_string_to_T  )
GRINSTesting::StringUtilitiesTest::CPPUNIT_TEST ( test_T_to_string  )
GRINSTesting::StringUtilitiesTest::CPPUNIT_TEST_SUITE ( StringUtilitiesTest  )
GRINSTesting::StringUtilitiesTest::CPPUNIT_TEST_SUITE_END ( )
void GRINSTesting::StringUtilitiesTest::test_split_string ( )
inline

Definition at line 54 of file string_utils.C.

References GRINS::StringUtilities::split_string(), and test_string().

55  {
56  {
57  std::string str_1("N->N2");
58  std::vector<std::string> test_1_split_exact(2);
59  test_1_split_exact[0] = std::string("N");
60  test_1_split_exact[1] = std::string("N2");
61 
62  std::vector<std::string> str_1_split;
63  GRINS::StringUtilities::split_string( str_1, "->", str_1_split);
64  this->test_string( str_1_split, test_1_split_exact );
65  }
66 
67  {
68  std::string str_2("N+C(s)->CN");
69  std::vector<std::string> test_2_split_exact(2);
70  test_2_split_exact[0] = std::string("N+C(s)");
71  test_2_split_exact[1] = std::string("CN");
72 
73  std::vector<std::string> str_2_split;
74  GRINS::StringUtilities::split_string( str_2, "->", str_2_split);
75  this->test_string( str_2_split, test_2_split_exact );
76  }
77 
78  {
79  std::string str_3("u:v:w:T:p:w_N:w_N2:p0");
80  std::vector<std::string> test_3_split_exact(8);
81  test_3_split_exact[0] = std::string("u");
82  test_3_split_exact[1] = std::string("v");
83  test_3_split_exact[2] = std::string("w");
84  test_3_split_exact[3] = std::string("T");
85  test_3_split_exact[4] = std::string("p");
86  test_3_split_exact[5] = std::string("w_N");
87  test_3_split_exact[6] = std::string("w_N2");
88  test_3_split_exact[7] = std::string("p0");
89 
90  std::vector<std::string> str_3_split;
91  GRINS::StringUtilities::split_string( str_3, ":", str_3_split);
92  this->test_string( str_3_split, test_3_split_exact );
93  }
94 
95  {
96  std::string str_4("u v w T p w_N w_N2 p0");
97  std::vector<std::string> test_4_split_exact(8);
98  test_4_split_exact[0] = std::string("u");
99  test_4_split_exact[1] = std::string("v");
100  test_4_split_exact[2] = std::string("w");
101  test_4_split_exact[3] = std::string("T");
102  test_4_split_exact[4] = std::string("p");
103  test_4_split_exact[5] = std::string("w_N");
104  test_4_split_exact[6] = std::string("w_N2");
105  test_4_split_exact[7] = std::string("p0");
106 
107  std::vector<std::string> str_4_split;
108  GRINS::StringUtilities::split_string( str_4, " ", str_4_split);
109  this->test_string( str_4_split, test_4_split_exact );
110  }
111  }
void test_string(const std::vector< std::string > &test, const std::vector< std::string > &exact)
Definition: string_utils.C:151
void split_string(const std::string &input, const std::string &delimiter, std::vector< std::string > &results)
Definition: string_utils.C:31
void GRINSTesting::StringUtilitiesTest::test_string ( const std::vector< std::string > &  test,
const std::vector< std::string > &  exact 
)
inlineprivate

Definition at line 151 of file string_utils.C.

Referenced by test_split_string().

153  {
154  CPPUNIT_ASSERT_EQUAL(test.size(), exact.size() );
155 
156  for( unsigned int s = 0; s < test.size(); s++ )
157  CPPUNIT_ASSERT_EQUAL( test[s], exact[s] );
158  }
int test(ChemicalMixture &chem_mixture)
void GRINSTesting::StringUtilitiesTest::test_string_to_T ( )
inline

Definition at line 113 of file string_utils.C.

114  {
115  std::string one = "1";
116  int ione = GRINS::StringUtilities::string_to_T<int>(one);
117  unsigned int uione = GRINS::StringUtilities::string_to_T<unsigned int>(one);
118  CPPUNIT_ASSERT_EQUAL(1,ione);
119  CPPUNIT_ASSERT_EQUAL((unsigned int)1,uione);
120 
121  std::string tenp1 = "10.1";
122  double dtenp1 = GRINS::StringUtilities::string_to_T<double>(tenp1);
123  CPPUNIT_ASSERT_DOUBLES_EQUAL(10.1,
124  dtenp1,
125  std::numeric_limits<double>::epsilon());
126  }
void GRINSTesting::StringUtilitiesTest::test_T_to_string ( )
inline

Definition at line 128 of file string_utils.C.

129  {
130  std::string one_exact = "1";
131  std::string tenp1_exact = "10.1";
132 
133  {
134  std::string one_test = GRINS::StringUtilities::T_to_string<int>(1);
135  CPPUNIT_ASSERT_EQUAL(one_exact,one_test);
136  }
137 
138  {
139  std::string one_test = GRINS::StringUtilities::T_to_string<unsigned int>(1);
140  CPPUNIT_ASSERT_EQUAL(one_exact,one_test);
141  }
142 
143  {
144  std::string tenp1_test = GRINS::StringUtilities::T_to_string<double>(10.1);
145  CPPUNIT_ASSERT_EQUAL(tenp1_exact,tenp1_test);
146  }
147  }

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

Generated on Thu Jun 2 2016 21:52:33 for GRINS-0.7.0 by  doxygen 1.8.10