QJniArray: add test case for QJniArray::size
Fix build of the test by removing the reference from the container type before accessing the nested typedef. Pick-to: 6.7 Change-Id: Ic35f312bac70b8f8f80149a3432329070c8c8c7d Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
parent
2a832b40af
commit
2c9525a501
@ -11,6 +11,7 @@
|
|||||||
#include <QtCore/qjniobject.h>
|
#include <QtCore/qjniobject.h>
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -87,7 +88,7 @@ public:
|
|||||||
>
|
>
|
||||||
static auto fromContainer(Container &&container)
|
static auto fromContainer(Container &&container)
|
||||||
{
|
{
|
||||||
using ElementType = typename Container::value_type;
|
using ElementType = typename std::remove_reference_t<Container>::value_type;
|
||||||
if constexpr (std::disjunction_v<std::is_same<ElementType, jobject>,
|
if constexpr (std::disjunction_v<std::is_same<ElementType, jobject>,
|
||||||
std::is_same<ElementType, QJniObject>>) {
|
std::is_same<ElementType, QJniObject>>) {
|
||||||
return makeObjectArray(std::forward<Container>(container));
|
return makeObjectArray(std::forward<Container>(container));
|
||||||
|
@ -14,6 +14,9 @@ class tst_QJniArray : public QObject
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
tst_QJniArray() = default;
|
tst_QJniArray() = default;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void size();
|
||||||
};
|
};
|
||||||
|
|
||||||
using namespace QtJniTypes;
|
using namespace QtJniTypes;
|
||||||
@ -70,6 +73,18 @@ VERIFY_RETURN_FOR_TYPE(QList<double>, QList<double>);
|
|||||||
|
|
||||||
VERIFY_RETURN_FOR_TYPE(QString, QString);
|
VERIFY_RETURN_FOR_TYPE(QString, QString);
|
||||||
|
|
||||||
|
void tst_QJniArray::size()
|
||||||
|
{
|
||||||
|
QJniArray<jint> array;
|
||||||
|
QVERIFY(!array.isValid());
|
||||||
|
QCOMPARE(array.size(), 0);
|
||||||
|
|
||||||
|
QList<int> intList;
|
||||||
|
intList.resize(10);
|
||||||
|
auto intArray = QJniArrayBase::fromContainer(intList);
|
||||||
|
QCOMPARE(intArray.size(), 10);
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_QJniArray)
|
QTEST_MAIN(tst_QJniArray)
|
||||||
|
|
||||||
#include "tst_qjniarray.moc"
|
#include "tst_qjniarray.moc"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user