temptest.cpp 2.1 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 "temptest.h"
  23. #include <QtTest/QtTest>
  24. void TempTest::initTestCase()
  25. {
  26. m_tempString = QStringLiteral("25");
  27. m_temp = new TestTemp(&m_tempString);
  28. }
  29. void TempTest::cleanupTestCase()
  30. {
  31. delete m_temp;
  32. }
  33. void TempTest::init()
  34. {
  35. // Called before each testfunction is executed
  36. }
  37. void TempTest::cleanup()
  38. {
  39. // Called after every testfunction
  40. }
  41. void TempTest::nameTest_data()
  42. {
  43. QTest::addColumn<QString>("name");
  44. QTest::newRow("radeon") << "radeon";
  45. QTest::newRow("cpu") << "cpu";
  46. }
  47. void TempTest::nameTest()
  48. {
  49. QFETCH(QString, name);
  50. m_temp->setName(name);
  51. QCOMPARE(m_temp->name(), name);
  52. }
  53. void TempTest::valueTest_data()
  54. {
  55. QTest::addColumn<QString>("value");
  56. QTest::addColumn<int>("result");
  57. QTest::newRow("0") << "0" << 0;
  58. QTest::newRow("10") << "10000" << 10;
  59. QTest::newRow("100") << "100000" << 100;
  60. QTest::newRow("55") << "55000" << 55;
  61. }
  62. void TempTest::valueTest()
  63. {
  64. QFETCH(QString, value);
  65. QFETCH(int, result);
  66. m_tempString = value;
  67. m_temp->update();
  68. QCOMPARE(m_temp->value(), result);
  69. }
  70. QTEST_MAIN(TempTest)