void test_split_string() { { std::string str_1("N->N2"); std::vector<std::string> test_1_split_exact(2); test_1_split_exact[0] = std::string("N"); test_1_split_exact[1] = std::string("N2"); std::vector<std::string> str_1_split; GRINS::StringUtilities::split_string( str_1, "->", str_1_split); this->test_string( str_1_split, test_1_split_exact ); } { std::string str_2("N+C(s)->CN"); std::vector<std::string> test_2_split_exact(2); test_2_split_exact[0] = std::string("N+C(s)"); test_2_split_exact[1] = std::string("CN"); std::vector<std::string> str_2_split; GRINS::StringUtilities::split_string( str_2, "->", str_2_split); this->test_string( str_2_split, test_2_split_exact ); } { std::string str_3("u:v:w:T:p:w_N:w_N2:p0"); std::vector<std::string> test_3_split_exact(8); test_3_split_exact[0] = std::string("u"); test_3_split_exact[1] = std::string("v"); test_3_split_exact[2] = std::string("w"); test_3_split_exact[3] = std::string("T"); test_3_split_exact[4] = std::string("p"); test_3_split_exact[5] = std::string("w_N"); test_3_split_exact[6] = std::string("w_N2"); test_3_split_exact[7] = std::string("p0"); std::vector<std::string> str_3_split; GRINS::StringUtilities::split_string( str_3, ":", str_3_split); this->test_string( str_3_split, test_3_split_exact ); } { std::string str_4("u v w T p w_N w_N2 p0"); std::vector<std::string> test_4_split_exact(8); test_4_split_exact[0] = std::string("u"); test_4_split_exact[1] = std::string("v"); test_4_split_exact[2] = std::string("w"); test_4_split_exact[3] = std::string("T"); test_4_split_exact[4] = std::string("p"); test_4_split_exact[5] = std::string("w_N"); test_4_split_exact[6] = std::string("w_N2"); test_4_split_exact[7] = std::string("p0"); std::vector<std::string> str_4_split; GRINS::StringUtilities::split_string( str_4, " ", str_4_split); this->test_string( str_4_split, test_4_split_exact ); } }
int main() { int return_flag = 0; std::string str_1("N->N2"); std::vector<std::string> test_1_split_exact(2); test_1_split_exact[0] = std::string("N"); test_1_split_exact[1] = std::string("N2"); std::vector<std::string> str_1_split; GRINS::StringUtilities::split_string( str_1, "->", str_1_split); if( !test_string( str_1_split, test_1_split_exact ) ) return_flag = 1; std::string str_2("N+C(s)->CN"); std::vector<std::string> test_2_split_exact(2); test_2_split_exact[0] = std::string("N+C(s)"); test_2_split_exact[1] = std::string("CN"); std::vector<std::string> str_2_split; GRINS::StringUtilities::split_string( str_2, "->", str_2_split); if( !test_string( str_2_split, test_2_split_exact ) ) return_flag = 1; std::string str_3("u:v:w:T:p:w_N:w_N2:p0"); std::vector<std::string> test_3_split_exact(8); test_3_split_exact[0] = std::string("u"); test_3_split_exact[1] = std::string("v"); test_3_split_exact[2] = std::string("w"); test_3_split_exact[3] = std::string("T"); test_3_split_exact[4] = std::string("p"); test_3_split_exact[5] = std::string("w_N"); test_3_split_exact[6] = std::string("w_N2"); test_3_split_exact[7] = std::string("p0"); std::vector<std::string> str_3_split; GRINS::StringUtilities::split_string( str_3, ":", str_3_split); if( !test_string( str_3_split, test_3_split_exact ) ) return_flag = 1; std::string str_4("u v w T p w_N w_N2 p0"); std::vector<std::string> test_4_split_exact(8); test_4_split_exact[0] = std::string("u"); test_4_split_exact[1] = std::string("v"); test_4_split_exact[2] = std::string("w"); test_4_split_exact[3] = std::string("T"); test_4_split_exact[4] = std::string("p"); test_4_split_exact[5] = std::string("w_N"); test_4_split_exact[6] = std::string("w_N2"); test_4_split_exact[7] = std::string("p0"); std::vector<std::string> str_4_split; GRINS::StringUtilities::split_string( str_4, " ", str_4_split); if( !test_string( str_4_split, test_4_split_exact ) ) return_flag = 1; return return_flag; }