93SCENARIO(
"Parsing times in x:m:s format",
"[tcsInterface]" )
95 GIVEN(
"A valid x:m:s string" )
99 WHEN(
"Positive, double digit integers" )
101 tcsInterface_test tit(
"tcsi" );
103 std::string tstr =
"12:20:50";
109 rv = tit.parse_xms( x, m, s, tstr );
112 REQUIRE_THAT( x, Catch::Matchers::WithinAbs( 12, 1e-10 ) );
113 REQUIRE_THAT( m, Catch::Matchers::WithinAbs( 20, 1e-10 ) );
114 REQUIRE_THAT( s, Catch::Matchers::WithinAbs( 50, 1e-10 ) );
117 WHEN(
"Negative, double digit integers" )
119 tcsInterface_test tit(
"tcsi" );
121 std::string tstr =
"-22:30:48";
127 rv = tit.parse_xms( x, m, s, tstr );
130 REQUIRE_THAT( x, Catch::Matchers::WithinAbs( -22, 1e-10 ) );
131 REQUIRE_THAT( m, Catch::Matchers::WithinAbs( -30, 1e-10 ) );
132 REQUIRE_THAT( s, Catch::Matchers::WithinAbs( -48, 1e-10 ) );
135 WHEN(
"Positive, double digit, decimal seconds" )
137 tcsInterface_test tit(
"tcsi" );
139 std::string tstr =
"12:20:50.267849";
145 rv = tit.parse_xms( x, m, s, tstr );
148 REQUIRE_THAT( x, Catch::Matchers::WithinAbs( 12, 1e-10 ) );
149 REQUIRE_THAT( m, Catch::Matchers::WithinAbs( 20, 1e-10 ) );
150 REQUIRE_THAT( s, Catch::Matchers::WithinAbs( 50.267849, 1e-10 ) );
153 WHEN(
"Negative, double digit integers" )
155 tcsInterface_test tit(
"tcsi" );
157 std::string tstr =
"-22:30:48.8771819";
163 rv = tit.parse_xms( x, m, s, tstr );
166 REQUIRE_THAT( x, Catch::Matchers::WithinAbs( -22, 1e-10 ) );
167 REQUIRE_THAT( m, Catch::Matchers::WithinAbs( -30, 1e-10 ) );
168 REQUIRE_THAT( s, Catch::Matchers::WithinAbs( -48.8771819, 1e-10 ) );
172 GIVEN(
"Invalid x:m:s strings" )
178 tcsInterface_test tit(
"tcsi" );
180 std::string tstr =
"";
186 rv = tit.parse_xms( x, m, s, tstr );
193 tcsInterface_test tit(
"tcsi" );
195 std::string tstr =
"12-20-50";
201 rv = tit.parse_xms( x, m, s, tstr );
208 tcsInterface_test tit(
"tcsi" );
210 std::string tstr =
"12:20-50";
216 rv = tit.parse_xms( x, m, s, tstr );
221 WHEN(
"two :, but one at beginning" )
223 tcsInterface_test tit(
"tcsi" );
225 std::string tstr =
":12:20";
231 rv = tit.parse_xms( x, m, s, tstr );
236 WHEN(
"two :, but no m" )
238 tcsInterface_test tit(
"tcsi" );
240 std::string tstr =
"12::20";
246 rv = tit.parse_xms( x, m, s, tstr );
251 WHEN(
"two :, but one at end" )
253 tcsInterface_test tit(
"tcsi" );
255 std::string tstr =
"12:20:";
261 rv = tit.parse_xms( x, m, s, tstr );
268 tcsInterface_test tit(
"tcsi" );
270 std::string tstr =
"x:20:80";
276 rv = tit.parse_xms( x, m, s, tstr );
283 tcsInterface_test tit(
"tcsi" );
285 std::string tstr =
"-x:20:80";
291 rv = tit.parse_xms( x, m, s, tstr );
298 tcsInterface_test tit(
"tcsi" );
300 std::string tstr =
"20:m:80";
306 rv = tit.parse_xms( x, m, s, tstr );
313 tcsInterface_test tit(
"tcsi" );
315 std::string tstr =
"-12:m:80";
321 rv = tit.parse_xms( x, m, s, tstr );
328 tcsInterface_test tit(
"tcsi" );
330 std::string tstr =
"20:23:s.ssy";
336 rv = tit.parse_xms( x, m, s, tstr );
343 tcsInterface_test tit(
"tcsi" );
345 std::string tstr =
"-12:23:s.sye";
351 rv = tit.parse_xms( x, m, s, tstr );