@@ -115,19 +115,36 @@ TEST_CASE("Test split") {
115115
116116 std::string s3 = " ;abc;def" ;
117117 std::vector<std::string> vs3 = stringtoolbox::split (s3, ' ;' );
118- REQUIRE (vs3.size () == 2 );
119- REQUIRE (vs3.at (0 ) == " abc" );
120- REQUIRE (vs3.at (1 ) == " def" );
118+ REQUIRE (vs3.size () == 3 );
119+ REQUIRE (vs3.at (1 ) == " abc" );
120+ REQUIRE (vs3.at (2 ) == " def" );
121121
122122 std::string s4 = " abc;def;" ;
123123 std::vector<std::string> vs4 = stringtoolbox::split (s4, ' ;' );
124- REQUIRE (vs4.size () == 2 );
124+ REQUIRE (vs4.size () == 3 );
125125 REQUIRE (vs4.at (0 ) == " abc" );
126126 REQUIRE (vs4.at (1 ) == " def" );
127127
128128 std::string s5 = " ;abc;def;" ;
129129 std::vector<std::string> vs5 = stringtoolbox::split (s5, ' ;' );
130- REQUIRE (vs5.size () == 2 );
131- REQUIRE (vs5.at (0 ) == " abc" );
132- REQUIRE (vs5.at (1 ) == " def" );
130+ REQUIRE (vs5.size () == 4 );
131+ REQUIRE (vs5.at (1 ) == " abc" );
132+ REQUIRE (vs5.at (2 ) == " def" );
133+
134+ std::string s6 = " ;abc;;def;" ;
135+ std::vector<std::string> vs6 = stringtoolbox::split (s6, ' ;' );
136+ REQUIRE (vs6.size () == 5 );
137+ REQUIRE (vs6.at (1 ) == " abc" );
138+ REQUIRE (vs6.at (3 ) == " def" );
139+ }
140+
141+ TEST_CASE (" Empty field" ) {
142+ std::string s1 = " 1;0;;57.71941;11.95701" ;
143+ std::vector<std::string> vs1 = stringtoolbox::split (s1, ' ;' );
144+ REQUIRE (vs1.size () == 5 );
145+ REQUIRE (vs1.at (0 ) == " 1" );
146+ REQUIRE (vs1.at (1 ) == " 0" );
147+ REQUIRE (vs1.at (2 ) == " " );
148+ REQUIRE (vs1.at (3 ) == " 57.71941" );
149+ REQUIRE (vs1.at (4 ) == " 11.95701" );
133150}
0 commit comments