fantest.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 "fantest.h"
  23. #include <QtTest/QtTest>
  24. void FanTest::initTestCase()
  25. {
  26. m_rpmString = QStringLiteral("500");
  27. m_fan = new TestFan(&m_rpmString);
  28. }
  29. void FanTest::cleanupTestCase()
  30. {
  31. delete m_fan;
  32. }
  33. void FanTest::init()
  34. {
  35. // Called before each testfunction is executed
  36. }
  37. void FanTest::cleanup()
  38. {
  39. // Called after every testfunction
  40. }
  41. void FanTest::nameTest_data()
  42. {
  43. QTest::addColumn<QString>("name");
  44. QTest::newRow("BigFan") << "BigFan";
  45. QTest::newRow("fan2") << "fan2";
  46. }
  47. void FanTest::nameTest()
  48. {
  49. QFETCH(QString, name);
  50. m_fan->setName(name);
  51. QCOMPARE(m_fan->name(), name);
  52. }
  53. void FanTest::rpmTest_data()
  54. {
  55. QTest::addColumn<QString>("value");
  56. QTest::addColumn<int>("result");
  57. QTest::newRow("0") << "0" << 0;
  58. QTest::newRow("100") << "100" << 100;
  59. QTest::newRow("1000") << "1000" << 1000;
  60. QTest::newRow("5500") << "5500" << 5500;
  61. }
  62. void FanTest::rpmTest()
  63. {
  64. QFETCH(QString, value);
  65. QFETCH(int, result);
  66. m_rpmString = value;
  67. m_fan->update();
  68. QCOMPARE(m_fan->rpm(), result);
  69. }
  70. QTEST_MAIN(FanTest)