@@ -75,22 +75,34 @@ TEST_SUBMODULE(pytypes, m) {
7575 m.def (" get_none" , [] { return py::none (); });
7676 m.def (" print_none" , [](const py::none &none) { py::print (" none: {}" _s.format (none)); });
7777
78- // test_set
78+ // test_set, test_frozenset
7979 m.def (" get_set" , []() {
8080 py::set set;
8181 set.add (py::str (" key1" ));
8282 set.add (" key2" );
8383 set.add (std::string (" key3" ));
8484 return set;
8585 });
86- m.def (" print_set" , [](const py::set &set) {
86+ m.def (" get_frozenset" , []() {
87+ py::set set;
88+ set.add (py::str (" key1" ));
89+ set.add (" key2" );
90+ set.add (std::string (" key3" ));
91+ return py::frozenset (set);
92+ });
93+ m.def (" print_anyset" , [](const py::anyset &set) {
8794 for (auto item : set) {
8895 py::print (" key:" , item);
8996 }
9097 });
91- m.def (" set_contains" ,
92- [](const py::set &set, const py::object &key) { return set.contains (key); });
93- m.def (" set_contains" , [](const py::set &set, const char *key) { return set.contains (key); });
98+ m.def (" anyset_size" , [](const py::anyset &set) { return set.size (); });
99+ m.def (" anyset_empty" , [](const py::anyset &set) { return set.empty (); });
100+ m.def (" anyset_contains" ,
101+ [](const py::anyset &set, const py::object &key) { return set.contains (key); });
102+ m.def (" anyset_contains" ,
103+ [](const py::anyset &set, const char *key) { return set.contains (key); });
104+ m.def (" set_add" , [](py::set &set, const py::object &key) { set.add (key); });
105+ m.def (" set_clear" , [](py::set &set) { set.clear (); });
94106
95107 // test_dict
96108 m.def (" get_dict" , []() { return py::dict (" key" _a = " value" ); });
@@ -310,6 +322,7 @@ TEST_SUBMODULE(pytypes, m) {
310322 " list" _a = py::list (d[" list" ]),
311323 " dict" _a = py::dict (d[" dict" ]),
312324 " set" _a = py::set (d[" set" ]),
325+ " frozenset" _a = py::frozenset (d[" frozenset" ]),
313326 " memoryview" _a = py::memoryview (d[" memoryview" ]));
314327 });
315328
@@ -325,6 +338,7 @@ TEST_SUBMODULE(pytypes, m) {
325338 " list" _a = d[" list" ].cast <py::list>(),
326339 " dict" _a = d[" dict" ].cast <py::dict>(),
327340 " set" _a = d[" set" ].cast <py::set>(),
341+ " frozenset" _a = d[" frozenset" ].cast <py::frozenset>(),
328342 " memoryview" _a = d[" memoryview" ].cast <py::memoryview>());
329343 });
330344
0 commit comments