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

Function test_brace_initialization

tests/test_class.py:395–405  ·  view source on GitHub ↗

Tests that simple POD classes can be constructed using C++11 brace initialization

()

Source from the content-addressed store, hash-verified

393
394
395def test_brace_initialization():
396 """Tests that simple POD classes can be constructed using C++11 brace initialization"""
397 a = m.BraceInitialization(123, "test")
398 assert a.field1 == 123
399 assert a.field2 == "test"
400
401 # Tests that a non-simple class doesn't get brace initialization (if the
402 # class defines an initializer_list constructor, in particular, it would
403 # win over the expected constructor).
404 b = m.NoBraceInitialization([123, 456])
405 assert b.vec == [123, 456]
406
407
408@pytest.mark.xfail("env.PYPY or env.GRAALPY")

Callers

nothing calls this directly

Calls 1

NoBraceInitializationMethod · 0.80

Tested by

no test coverage detected