I have 2 functions: serialise and deserialise, I want to check in the unit test whether they work correctly. But then the mistakes went up. and I don’t understand what I am saying is wrong. I need your help Test:
void UnitTests::testOne() { Task task1; task1.setQuestion("Вопрос"); task1.setAnswer("Ответ"); task1.setNumPoints(3); auto jsonObject = Archiver::serialise(&task1); Task task2 = Archiver::deserialise(&jsonObject); areEqual(task1, task2); } But the compiler shouts at these two lines.
Task task2 = Archiver::deserialise(&jsonObject); areEqual(task1, task2); Errors
1)error: C2664: 'std::unique_ptr<Component,std::default_delete<_Ty>> Archiver::deserialise(const QJsonObject &)': cannot convert argument 1 from 'std::unique_ptr<QJsonObject,std::default_delete<_Ty>> *' to 'const QJsonObject &' std :: unique_ptr Archiver :: deserialise (const QJsonObject & jsonData)
2) error: C3861: 'areEqual': identifier not found but I created the function Equal in the unit test.
UPD:
class UnitTests : public QObject { Q_OBJECT public: UnitTests(); private Q_SLOTS: void testOne(); void testSecond(); bool areEqual(const Component* comp1, const Component* comp2); }; void UnitTests::testOne() {} void UnitTests::testSecond() {} bool areEqual(const Component* comp1, const Component* comp2) {} QTEST_APPLESS_MAIN(UnitTests) #include "UnitTests.moc"