()
| 169 | not hasattr(m, "has_exp_optional"), reason="no <experimental/optional>" |
| 170 | ) |
| 171 | def test_exp_optional(): |
| 172 | assert m.double_or_zero_exp(None) == 0 |
| 173 | assert m.double_or_zero_exp(42) == 84 |
| 174 | pytest.raises(TypeError, m.double_or_zero_exp, "foo") |
| 175 | |
| 176 | assert m.half_or_none_exp(0) is None |
| 177 | assert m.half_or_none_exp(42) == 21 |
| 178 | pytest.raises(TypeError, m.half_or_none_exp, "foo") |
| 179 | |
| 180 | assert m.test_nullopt_exp() == 42 |
| 181 | assert m.test_nullopt_exp(None) == 42 |
| 182 | assert m.test_nullopt_exp(42) == 42 |
| 183 | assert m.test_nullopt_exp(43) == 43 |
| 184 | |
| 185 | assert m.test_no_assign_exp() == 42 |
| 186 | assert m.test_no_assign_exp(None) == 42 |
| 187 | assert m.test_no_assign_exp(m.NoAssign(43)) == 43 |
| 188 | pytest.raises(TypeError, m.test_no_assign_exp, 43) |
| 189 | |
| 190 | holder = m.OptionalExpHolder() |
| 191 | mvalue = holder.member |
| 192 | assert mvalue.initialized |
| 193 | assert holder.member_initialized() |
| 194 | |
| 195 | props = m.OptionalExpProperties() |
| 196 | assert int(props.access_by_ref) == 42 |
| 197 | assert int(props.access_by_copy) == 42 |
| 198 | |
| 199 | |
| 200 | @pytest.mark.skipif(not hasattr(m, "has_boost_optional"), reason="no <boost/optional>") |
nothing calls this directly
no test coverage detected