2
0

temptest.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright 2015 <copyright holder> <email>
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of
  7. * the License or (at your option) version 3 or any later version
  8. * accepted by the membership of KDE e.V. (or its successor approved
  9. * by the membership of KDE e.V.), which shall act as a proxy
  10. * defined in Section 14 of version 3 of the license.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. */
  21. #include "temptest.h"
  22. #include <QtTest/QtTest>
  23. void TempTest::initTestCase()
  24. {
  25. m_tempString = QStringLiteral("25");
  26. m_temp = new TestTemp(&m_tempString);
  27. }
  28. void TempTest::cleanupTestCase()
  29. {
  30. delete m_temp;
  31. }
  32. void TempTest::init()
  33. {
  34. // Called before each testfunction is executed
  35. }
  36. void TempTest::cleanup()
  37. {
  38. // Called after every testfunction
  39. }
  40. void TempTest::nameTest_data()
  41. {
  42. QTest::addColumn<QString>("name");
  43. QTest::newRow("radeon") << "radeon";
  44. QTest::newRow("cpu") << "cpu";
  45. }
  46. void TempTest::nameTest()
  47. {
  48. QFETCH(QString, name);
  49. m_temp->setName(name);
  50. QCOMPARE(m_temp->name(), name);
  51. }
  52. void TempTest::valueTest_data()
  53. {
  54. QTest::addColumn<QString>("value");
  55. QTest::addColumn<int>("result");
  56. QTest::newRow("0") << "0" << 0;
  57. QTest::newRow("10") << "10000" << 10;
  58. QTest::newRow("100") << "100000" << 100;
  59. QTest::newRow("55") << "55000" << 55;
  60. }
  61. void TempTest::valueTest()
  62. {
  63. QFETCH(QString, value);
  64. QFETCH(int, result);
  65. m_tempString = value;
  66. m_temp->update();
  67. QCOMPARE(m_temp->value(), result);
  68. }
  69. QTEST_MAIN(TempTest)