Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTest::addColumn<QObject>
QtWS25 Last Chance

QTest::addColumn<QObject>

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Exotic_Devel
    wrote on last edited by
    #1

    I am getting the error:

    In file included from /opt/Qt/5.3/gcc_64/include/QtCore/qobject.h:56:0,
    from /opt/Qt/5.3/gcc_64/include/QtCore/QObject:1,
    from ../../../TecTracker/Core/tests/testdataaccess.hpp:4,
    from ../../../TecTracker/Core/tests/testdataaccess.cpp:1:
    /opt/Qt/5.3/gcc_64/include/QtCore/qmetatype.h: In instantiation of 'int qMetaTypeId() [with T = QObject]':
    /opt/Qt/5.3/gcc_64/include/QtTest/qtestcase.h:282:42: required from 'void QTest::addColumn(const char*, T*) [with T = QObject]'
    ../../../TecTracker/Core/tests/testdataaccess.cpp:16:38: required from here
    /opt/Qt/5.3/gcc_64/include/QtCore/qmetatype.h:1615:44: error: invalid application of 'sizeof' to incomplete type 'QStaticAssertFailure<false>'
    Q_STATIC_ASSERT_X(QMetaTypeId2<T>::Defined, "Type is not registered, please use the Q_DECLARE_METATYPE macro to make it known to Qt's meta-object system");
    ^

    This is a test case for a class to connect to the database.

    the complete unity test code, below

    @#ifndef TESTDATAACCESS_HPP
    #define TESTDATAACCESS_HPP

    #include <QObject>
    #include<QtTest/QTest>

    class TestDataAccess : public QObject
    {

    Q_OBJECT

    public:
    explicit TestDataAccess(QObject *parent = 0);

    private Q_SLOTS:
    void testInstace();
    void testConection();
    void testConection_data();
    };

    #endif // TESTDATAACCESS_HPP
    @

    @#include "testdataaccess.hpp"
    #include "dataaccess.hpp"

    TestDataAccess::TestDataAccess(QObject *parent) : QObject(parent)
    {
    }

    void TestDataAccess::testInstace()
    {
    QVERIFY(DataAccess::instance());
    }

    void TestDataAccess::testConection_data()
    {
    QTest::addColumn<QObject>("parente");
    QTest::addColumn<bool>("banco");

    QTest::newRow("Normal") << this << true;
    QTest::newRow("Sem parente") << 0 << true;
    }

    void TestDataAccess::testConection()
    {
    QSqlDatabase *objdata;

    QFETCH(QObject*, parente);
    QFETCH(bool, banco);
    QCOMPARE(DataAccess::instance()->conection(objdata, parente)->open(), banco);

    delete objdata;
    }
    @

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      @QTest::addColumn<QObject>("parente");@

      You forget the *

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • E Offline
        E Offline
        Exotic_Devel
        wrote on last edited by
        #3

        @QTest::addColumn<QObject*>("parente");@

        This, produces big erros.

        http://fpaste.org/122398/

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          It seems you are not linking to the test module at least

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved