loadertest.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * <one line to give the library's name and an idea of what it does.>
  3. * Copyright 2015 <copyright holder> <email>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License or (at your option) version 3 or any later version
  9. * accepted by the membership of KDE e.V. (or its successor approved
  10. * by the membership of KDE e.V.), which shall act as a proxy
  11. * defined in Section 14 of version 3 of the license.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "loadertest.h"
  23. #include <QtTest/QtTest>
  24. #define COMMA ,
  25. QTEST_MAIN(LoaderTest);
  26. void LoaderTest::initTestCase()
  27. {
  28. m_loader = new Loader;
  29. }
  30. void LoaderTest::cleanupTestCase()
  31. {
  32. delete m_loader;
  33. }
  34. void LoaderTest::init()
  35. {
  36. // Called before each testfunction is executed
  37. }
  38. void LoaderTest::cleanup()
  39. {
  40. // Called after every testfunction
  41. }
  42. void LoaderTest::getEntryNumbersTest_data()
  43. {
  44. QTest::addColumn<QString>("entry");
  45. QTest::addColumn<QPair<int, int> >("result");
  46. QTest::newRow("valid1") << "hwmon0/temp1" << QPair<int, int>(0, 0);
  47. QTest::newRow("valid2") << "hwmon1/pwm2" << QPair<int, int>(1, 1);
  48. QTest::newRow("valid3") << "hwmon2/_input2" << QPair<int, int>(2, 1);
  49. QTest::newRow("valid4") << "hwmon3/fan1" << QPair<int, int>(3, 0);
  50. QTest::newRow("invalid1") << "hwmo0/temp1" << QPair<int, int>(-1, -1);
  51. QTest::newRow("invalid2") << "hwmonn0/temp1" << QPair<int, int>(-1, -1);
  52. QTest::newRow("invalid3") << "hwmon0/1" << QPair<int, int>(-1, -1);
  53. QTest::newRow("invalid4") << "hwmon0/pwmfan1" << QPair<int, int>(-1, -1);
  54. QTest::newRow("invalid5") << "hwmon0/fan1/temp3" << QPair<int, int>(-1, -1);
  55. }
  56. void LoaderTest::getEntryNumbersTest()
  57. {
  58. QFETCH(QString, entry);
  59. QFETCH(QPair<int COMMA int>, result);
  60. QCOMPARE(Loader::getEntryNumbers(entry), result);
  61. }
  62. void LoaderTest::parseConfigLineTest_data()
  63. {
  64. QTest::addColumn<QString>("line");
  65. QTest::addColumn<int>("result");
  66. }
  67. void LoaderTest::parseConfigLineTest()
  68. {
  69. }
  70. #include "loadertest.moc"