You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/testutils.cpp
+14Lines changed: 14 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -244,22 +244,36 @@ class TestUtils : public TestFixture {
244
244
ASSERT_THROW_EQUALS(::strToInt<int>("1.0"), std::runtime_error, "converting '1.0' to integer failed - not an integer (pos)");
245
245
ASSERT_THROW_EQUALS(::strToInt<int>("+1.0"), std::runtime_error, "converting '+1.0' to integer failed - not an integer (pos)");
246
246
ASSERT_THROW_EQUALS(::strToInt<int>("-1.0"), std::runtime_error, "converting '-1.0' to integer failed - not an integer (pos)");
247
+
ASSERT_THROW_EQUALS(::strToInt<int>("1U"), std::runtime_error, "converting '1U' to integer failed - not an integer (pos)");
248
+
ASSERT_THROW_EQUALS(::strToInt<int>("1L"), std::runtime_error, "converting '1L' to integer failed - not an integer (pos)");
249
+
ASSERT_THROW_EQUALS(::strToInt<int>("1Z"), std::runtime_error, "converting '1Z' to integer failed - not an integer (pos)");
250
+
// ASSERT_THROW_EQUALS(::strToInt<int>("01"), std::runtime_error, "converting '01' to integer failed - not an integer"); // TODO: should fail
251
+
ASSERT_THROW_EQUALS(::strToInt<int>("0x1"), std::runtime_error, "converting '0x1' to integer failed - not an integer (pos)");
252
+
ASSERT_THROW_EQUALS(::strToInt<int>("0b1"), std::runtime_error, "converting '0b1' to integer failed - not an integer (pos)");
247
253
ASSERT_THROW_EQUALS(::strToInt<int>("one"), std::runtime_error, "converting 'one' to integer failed - not an integer (invalid_argument)");
248
254
ASSERT_THROW_EQUALS(::strToInt<int>(" 1"), std::runtime_error, "converting ' 1' to integer failed - not an integer");
249
255
ASSERT_THROW_EQUALS(::strToInt<int>("\t1"), std::runtime_error, "converting '\t1' to integer failed - not an integer");
250
256
ASSERT_THROW_EQUALS(::strToInt<int>("1 "), std::runtime_error, "converting '1 ' to integer failed - not an integer (pos)");
251
257
ASSERT_THROW_EQUALS(::strToInt<int>("1\t"), std::runtime_error, "converting '1\t' to integer failed - not an integer (pos)");
252
258
ASSERT_THROW_EQUALS(::strToInt<int>("+ 1"), std::runtime_error, "converting '+ 1' to integer failed - not an integer (invalid_argument)");
259
+
ASSERT_THROW_EQUALS(::strToInt<int>("O1"), std::runtime_error, "converting 'O1' to integer failed - not an integer (invalid_argument)");
253
260
ASSERT_THROW_EQUALS(::strToInt<unsignedint>("1ms"), std::runtime_error, "converting '1ms' to integer failed - not an integer (pos)");
254
261
ASSERT_THROW_EQUALS(::strToInt<unsignedint>("1.0"), std::runtime_error, "converting '1.0' to integer failed - not an integer (pos)");
255
262
ASSERT_THROW_EQUALS(::strToInt<unsignedint>("+1.0"), std::runtime_error, "converting '+1.0' to integer failed - not an integer (pos)");
256
263
ASSERT_THROW_EQUALS(::strToInt<unsignedint>("-1.0"), std::runtime_error, "converting '-1.0' to integer failed - not an integer (pos)");
264
+
ASSERT_THROW_EQUALS(::strToInt<unsignedint>("1U"), std::runtime_error, "converting '1U' to integer failed - not an integer (pos)");
265
+
ASSERT_THROW_EQUALS(::strToInt<unsignedint>("1L"), std::runtime_error, "converting '1L' to integer failed - not an integer (pos)");
266
+
ASSERT_THROW_EQUALS(::strToInt<unsignedint>("1Z"), std::runtime_error, "converting '1Z' to integer failed - not an integer (pos)");
267
+
// ASSERT_THROW_EQUALS(::strToInt<unsigned int>("01"), std::runtime_error, "converting '01' to integer failed - not an integer"); // TODO: should fail
268
+
ASSERT_THROW_EQUALS(::strToInt<unsignedint>("0x1"), std::runtime_error, "converting '0x1' to integer failed - not an integer (pos)");
269
+
ASSERT_THROW_EQUALS(::strToInt<unsignedint>("0b1"), std::runtime_error, "converting '0b1' to integer failed - not an integer (pos)");
257
270
ASSERT_THROW_EQUALS(::strToInt<unsignedint>("one"), std::runtime_error, "converting 'one' to integer failed - not an integer (invalid_argument)");
258
271
ASSERT_THROW_EQUALS(::strToInt<unsignedint>(" 1"), std::runtime_error, "converting ' 1' to integer failed - not an integer");
259
272
ASSERT_THROW_EQUALS(::strToInt<unsignedint>("\t1"), std::runtime_error, "converting '\t1' to integer failed - not an integer");
260
273
ASSERT_THROW_EQUALS(::strToInt<unsignedint>("1 "), std::runtime_error, "converting '1 ' to integer failed - not an integer (pos)");
261
274
ASSERT_THROW_EQUALS(::strToInt<unsignedint>("1\t"), std::runtime_error, "converting '1\t' to integer failed - not an integer (pos)");
262
275
ASSERT_THROW_EQUALS(::strToInt<unsignedint>("- 1"), std::runtime_error, "converting '- 1' to integer failed - not an integer (invalid_argument)");
276
+
ASSERT_THROW_EQUALS(::strToInt<unsignedint>("O1"), std::runtime_error, "converting 'O1' to integer failed - not an integer (invalid_argument)");
263
277
ASSERT_THROW_EQUALS(::strToInt<int>(std::to_string(static_cast<int64_t>(std::numeric_limits<int>::max()) + 1)), std::runtime_error, "converting '2147483648' to integer failed - out of range (limits)");
264
278
ASSERT_THROW_EQUALS(::strToInt<int>(std::to_string(static_cast<int64_t>(std::numeric_limits<int>::min()) - 1)), std::runtime_error, "converting '-2147483649' to integer failed - out of range (limits)");
265
279
ASSERT_THROW_EQUALS(::strToInt<int8_t>(std::to_string(static_cast<int64_t>(std::numeric_limits<int8_t>::max()) + 1)), std::runtime_error, "converting '128' to integer failed - out of range (limits)");
0 commit comments