27 #include "antioch_config.h"
29 #ifdef ANTIOCH_HAVE_CPPUNIT
31 #include <cppunit/extensions/HelperMacros.h>
32 #include <cppunit/TestCase.h>
60 std::string str(
"N->N2");
61 std::vector<std::string> str_split;
64 CPPUNIT_ASSERT_EQUAL(2,(
int)str_split.size());
65 CPPUNIT_ASSERT_EQUAL(str_split[0],std::string(
"N"));
66 CPPUNIT_ASSERT_EQUAL(str_split[1],std::string(
"N2"));
70 std::string str(
"N+C(s)->CN");
71 std::vector<std::string> str_split;
74 CPPUNIT_ASSERT_EQUAL(2,(
int)str_split.size());
75 CPPUNIT_ASSERT_EQUAL(str_split[0],std::string(
"N+C(s)"));
76 CPPUNIT_ASSERT_EQUAL(str_split[1],std::string(
"CN"));
80 std::string str(
"u:v:w:T:p:w_N:w_N2:p0");
81 std::vector<std::string> str_split;
84 CPPUNIT_ASSERT_EQUAL(8,(
int)str_split.size());
85 CPPUNIT_ASSERT_EQUAL(str_split[0],std::string(
"u"));
86 CPPUNIT_ASSERT_EQUAL(str_split[1],std::string(
"v"));
87 CPPUNIT_ASSERT_EQUAL(str_split[2],std::string(
"w"));
88 CPPUNIT_ASSERT_EQUAL(str_split[3],std::string(
"T"));
89 CPPUNIT_ASSERT_EQUAL(str_split[4],std::string(
"p"));
90 CPPUNIT_ASSERT_EQUAL(str_split[5],std::string(
"w_N"));
91 CPPUNIT_ASSERT_EQUAL(str_split[6],std::string(
"w_N2"));
92 CPPUNIT_ASSERT_EQUAL(str_split[7],std::string(
"p0"));
96 std::string str(
"u v w T p w_N w_N2 p0");
97 std::vector<std::string> str_split;
100 CPPUNIT_ASSERT_EQUAL(8,(
int)str_split.size());
101 CPPUNIT_ASSERT_EQUAL(str_split[0],std::string(
"u"));
102 CPPUNIT_ASSERT_EQUAL(str_split[1],std::string(
"v"));
103 CPPUNIT_ASSERT_EQUAL(str_split[2],std::string(
"w"));
104 CPPUNIT_ASSERT_EQUAL(str_split[3],std::string(
"T"));
105 CPPUNIT_ASSERT_EQUAL(str_split[4],std::string(
"p"));
106 CPPUNIT_ASSERT_EQUAL(str_split[5],std::string(
"w_N"));
107 CPPUNIT_ASSERT_EQUAL(str_split[6],std::string(
"w_N2"));
108 CPPUNIT_ASSERT_EQUAL(str_split[7],std::string(
"p0"));
112 std::string str(
"2.25853318e+03, -1.57454401e+00, 2.50363759e+00, -5.20253954e-06, ");
113 str +=
" 4.51647956e-09, -2.18115104e-12, 4.49430845e-16, 2.16895191e+05, 4.34577527e+00";
115 std::vector<std::string> str_split;
118 CPPUNIT_ASSERT_EQUAL(9,(
int)str_split.size());
119 CPPUNIT_ASSERT_EQUAL(str_split[0],std::string(
"2.25853318e+03"));
120 CPPUNIT_ASSERT_EQUAL(str_split[1],std::string(
"-1.57454401e+00"));
121 CPPUNIT_ASSERT_EQUAL(str_split[2],std::string(
"2.50363759e+00"));
122 CPPUNIT_ASSERT_EQUAL(str_split[3],std::string(
"-5.20253954e-06"));
123 CPPUNIT_ASSERT_EQUAL(str_split[4],std::string(
"4.51647956e-09"));
124 CPPUNIT_ASSERT_EQUAL(str_split[5],std::string(
"-2.18115104e-12"));
125 CPPUNIT_ASSERT_EQUAL(str_split[6],std::string(
"4.49430845e-16"));
126 CPPUNIT_ASSERT_EQUAL(str_split[7],std::string(
"2.16895191e+05"));
127 CPPUNIT_ASSERT_EQUAL(str_split[8],std::string(
"4.34577527e+00"));
134 std::string str(
"1");
135 int test = Antioch::string_to_T<int>(str);
136 CPPUNIT_ASSERT_EQUAL(1,test);
140 std::string str(
"1.0");
141 double test = Antioch::string_to_T<double>(str);
142 CPPUNIT_ASSERT_EQUAL(1.0,test);
146 std::string str(
"4.34577527e+00");
147 double test = Antioch::string_to_T<double>(str);
148 CPPUNIT_ASSERT_DOUBLES_EQUAL(4.34577527e+00, test, 1.0e-8);
155 std::vector<std::string> strings;
156 strings.push_back(
"\n");
157 strings.push_back(
"2.9087450987e-01\n");
158 strings.push_back(
"3.1415926539e+00\n");
159 strings.push_back(
"1.1111111111e+10\n");
161 std::vector<std::string> strings_exact;
162 strings_exact.push_back(
"2.9087450987e-01");
163 strings_exact.push_back(
"3.1415926539e+00");
164 strings_exact.push_back(
"1.1111111111e+10");
167 CPPUNIT_ASSERT_EQUAL(strings_exact.size(), strings.size());
169 for(
unsigned int i = 0; i < strings_exact.size(); i++ )
170 CPPUNIT_ASSERT_EQUAL(strings_exact[i], strings[i]);
179 #endif // ANTIOCH_HAVE_CPPUNIT
void remove_newline_from_strings(std::vector< std::string > &strings)
Strips newline characters from strings in the input vector, strings.
void split_string(const std::string &input, const std::string &delimiter, std::vector< std::string > &results)
All characters in delimiter will be treated as a delimiter.
void test_strip_newlines()
CPPUNIT_TEST_SUITE(StringUtilitiesTest)
CPPUNIT_TEST(test_split_string)
CPPUNIT_TEST_SUITE_REGISTRATION(ArrheniusRateEigenFloatTest)