MCPcopy Create free account
hub / github.com/pybind/pybind11 / test_integer_casting

Function test_integer_casting

tests/test_builtin_casters.py:227–247  ·  view source on GitHub ↗

Issue #929 - out-of-range integer values shouldn't be accepted

()

Source from the content-addressed store, hash-verified

225
226
227def test_integer_casting():
228 """Issue #929 - out-of-range integer values shouldn't be accepted"""
229 assert m.i32_str(-1) == "-1"
230 assert m.i64_str(-1) == "-1"
231 assert m.i32_str(2000000000) == "2000000000"
232 assert m.u32_str(2000000000) == "2000000000"
233 assert m.i64_str(-999999999999) == "-999999999999"
234 assert m.u64_str(999999999999) == "999999999999"
235
236 with pytest.raises(TypeError) as excinfo:
237 m.u32_str(-1)
238 assert "incompatible function arguments" in str(excinfo.value)
239 with pytest.raises(TypeError) as excinfo:
240 m.u64_str(-1)
241 assert "incompatible function arguments" in str(excinfo.value)
242 with pytest.raises(TypeError) as excinfo:
243 m.i32_str(-3000000000)
244 assert "incompatible function arguments" in str(excinfo.value)
245 with pytest.raises(TypeError) as excinfo:
246 m.i32_str(3000000000)
247 assert "incompatible function arguments" in str(excinfo.value)
248
249
250def test_int_convert(doc):

Callers

nothing calls this directly

Calls 1

strClass · 0.85

Tested by

no test coverage detected