mirror of
https://github.com/ModOrganizer2/modorganizer-plugin_python.git
synced 2026-07-27 14:03:33 -07:00
Add some tests for QByteArray conversion.
This commit is contained in:
@@ -33,6 +33,14 @@ PYBIND11_MODULE(qt, m)
|
||||
return QString::number(value);
|
||||
});
|
||||
|
||||
// QByteArray
|
||||
m.def("create_qbytearray_from_raw", [](const char* raw) {
|
||||
return QByteArray(raw);
|
||||
});
|
||||
m.def("get_qbytearray_length", [](const QByteArray& data) {
|
||||
return data.size();
|
||||
});
|
||||
|
||||
// QStringList
|
||||
|
||||
m.def("qstringlist_join", [](QStringList const& values, QString const& sep) {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
from PyQt6.QtCore import QDateTime, Qt
|
||||
import struct
|
||||
|
||||
from PyQt6.QtCore import QByteArray, QDateTime, Qt
|
||||
|
||||
import mobase_tests.qt as m
|
||||
|
||||
@@ -23,6 +25,12 @@ def test_qstring():
|
||||
assert m.consume_qstring_with_emoji("🌎") == 2
|
||||
|
||||
|
||||
def test_qbytearray():
|
||||
arr = m.create_qbytearray_from_raw("hello world!")
|
||||
assert isinstance(arr, QByteArray)
|
||||
assert m.get_qbytearray_length(arr) == 12
|
||||
|
||||
|
||||
def test_qstringlist():
|
||||
assert m.qstringlist_join([""], "--") == ""
|
||||
assert m.qstringlist_join(["a", "b"], "") == "ab"
|
||||
|
||||
@@ -10,6 +10,9 @@ __all__ = [
|
||||
"SimpleEnum",
|
||||
"consume_qstring_with_emoji",
|
||||
"create_qstring_with_emoji",
|
||||
"create_qbytearray_from_raw",
|
||||
"get_qbytearray_length",
|
||||
"qbytearray_to_longlong",
|
||||
"datetime_from_string",
|
||||
"datetime_to_string",
|
||||
"int_to_qstring",
|
||||
@@ -92,6 +95,9 @@ def qflags_explode(arg0: int) -> tuple[int, bool, bool, bool]: ...
|
||||
def qmap_to_length(arg0: dict[str, str]) -> dict[str, int]: ...
|
||||
def qstring_to_int(arg0: str) -> int: ...
|
||||
def qstring_to_stdstring(arg0: str) -> str: ...
|
||||
def create_qbytearray_from_raw(arg0: str | bytes) -> PyQt6.QtCore.QByteArray: ...
|
||||
def get_qbytearray_length(arg0: PyQt6.QtCore.QByteArray) -> int: ...
|
||||
def qbytearray_to_longlong(arg0: PyQt6.QtCore.QByteArray) -> int: ...
|
||||
def qstringlist_at(arg0: typing.Sequence[str], arg1: int) -> str: ...
|
||||
def qstringlist_join(arg0: typing.Sequence[str], arg1: str) -> str: ...
|
||||
def qvariant_bool() -> MoVariant: ...
|
||||
|
||||
Reference in New Issue
Block a user