sequencetest.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * MIT License
  3. *
  4. * Copyright (c) 2022 Alexey Edelev <semlanik@gmail.com>, Viktor Kopp <vifactor@gmail.com>
  5. *
  6. * This file is part of QtProtobuf project https://git.semlanik.org/semlanik/qtprotobuf
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy of this
  9. * software and associated documentation files (the "Software"), to deal in the Software
  10. * without restriction, including without limitation the rights to use, copy, modify,
  11. * merge, publish, distribute, sublicense, and/or sell copies of the Software, and
  12. * to permit persons to whom the Software is furnished to do so, subject to the following
  13. * conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in all copies
  16. * or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  19. * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  20. * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
  21. * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  22. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  23. * DEALINGS IN THE SOFTWARE.
  24. */
  25. #ifndef QT_PROTOBUF_BASIC_MULTI_TEST
  26. #include "sequence.qpb.h"
  27. #endif
  28. #include <QMetaProperty>
  29. #include <QSignalSpy>
  30. #include <QtTest/QtTest>
  31. #include <qtprotobuftestscommon.h>
  32. class QtProtobufGenerationSequenceTest : public QObject
  33. {
  34. Q_OBJECT
  35. public:
  36. QtProtobufGenerationSequenceTest()
  37. {
  38. qRegisterProtobufTypes();
  39. }
  40. private slots:
  41. void SequenceTest();
  42. void CyclingTest();
  43. void MapRepeatedFieldSequenceTest();
  44. };
  45. using namespace qtprotobufnamespace::tests;
  46. void QtProtobufGenerationSequenceTest::SequenceTest()
  47. {
  48. qProtobufAssertMessagePropertyRegistered<sequence::TestMessageSequence, sequence::TestMessageSequence2*>(1, "qtprotobufnamespace::tests::sequence::TestMessageSequence2*", "testField");
  49. qProtobufAssertMessagePropertyRegistered<sequence::TestMessageSequence2, bool>(1, "bool", "testField");
  50. }
  51. void QtProtobufGenerationSequenceTest::CyclingTest()
  52. {
  53. qProtobufAssertMessagePropertyRegistered<sequence::CyclingFirstDependency, sequence::CyclingSecondDependency*>(1, "qtprotobufnamespace::tests::sequence::CyclingSecondDependency*", "testField");
  54. qProtobufAssertMessagePropertyRegistered<sequence::CyclingSecondDependency, sequence::CyclingFirstDependency*>(1, "qtprotobufnamespace::tests::sequence::CyclingFirstDependency*", "testField");
  55. sequence::CyclingFirstDependency test;
  56. sequence::CyclingSecondDependency test2;
  57. test.setTestField(test2);
  58. test2.setTestField(test);
  59. }
  60. void QtProtobufGenerationSequenceTest::MapRepeatedFieldSequenceTest()
  61. {
  62. qProtobufAssertMessagePropertyRegistered<sequence::RepeatedFieldSequence, sequence::RepeatedFieldSequence2Repeated>(1, "qtprotobufnamespace::tests::sequence::RepeatedFieldSequence2Repeated", "testFieldData");
  63. qProtobufAssertMessagePropertyRegistered<sequence::MapFieldSequence, sequence::MapFieldSequence::TestFieldEntry>(1, "qtprotobufnamespace::tests::sequence::MapFieldSequence::TestFieldEntry", "testField");
  64. }
  65. QTEST_MAIN(QtProtobufGenerationSequenceTest)
  66. #include "sequencetest.moc"