fix battery tests

This commit is contained in:
2017-12-17 04:29:23 +03:00
parent e5a9e99438
commit 423eabd857
2 changed files with 22 additions and 15 deletions

View File

@ -20,6 +20,8 @@
#include <QtTest>
#include <cmath>
#include "awtestlibrary.h"
#include "batterysource.h"
@ -39,13 +41,14 @@ void TestBatterySource::cleanupTestCase()
void TestBatterySource::test_sources()
{
QVERIFY(source->sources().count() >= 2);
//
QVERIFY(source->sources().count() >= 6);
}
void TestBatterySource::test_battery()
{
if (source->sources().count() == 2)
if (source->sources().count() == 6)
QSKIP("No battery found, test will be skipped");
QStringList batteries = source->sources();
@ -54,7 +57,7 @@ void TestBatterySource::test_battery()
if (bat == "battery/ac")
QCOMPARE(value.type(), QVariant::Bool);
else
QVERIFY((value.toFloat() >= battery.first) && (value.toFloat() <= battery.second));
QVERIFY((value.toFloat() >= battery.first) || (std::isnan(value.toFloat())));
});
}