File: test_union.cpp

package info (click to toggle)
hera 2.0.0%2Bgit20221115.8bfdd4b%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,120 kB
  • sloc: cpp: 30,506; python: 8,986; ansic: 2,088; sh: 49; makefile: 16
file content (22 lines) | stat: -rw-r--r-- 603 bytes parent folder | download | duplicates (21)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*
    tests/test_class.cpp -- test py::class_ definitions and basic functionality

    Copyright (c) 2019 Roland Dreier <roland.dreier@gmail.com>

    All rights reserved. Use of this source code is governed by a
    BSD-style license that can be found in the LICENSE file.
*/

#include "pybind11_tests.h"

TEST_SUBMODULE(union_, m) {
    union TestUnion {
        int value_int;
        unsigned value_uint;
    };

    py::class_<TestUnion>(m, "TestUnion")
        .def(py::init<>())
        .def_readonly("as_int", &TestUnion::value_int)
        .def_readwrite("as_uint", &TestUnion::value_uint);
}