diff options
| author | Oskari Timperi <oskari.timperi@iki.fi> | 2013-12-08 14:46:45 +0200 |
|---|---|---|
| committer | Oskari Timperi <oskari.timperi@iki.fi> | 2013-12-08 14:46:45 +0200 |
| commit | 6e444978a1c327c7cd98ded195478dc6906dc1b7 (patch) | |
| tree | cd80a2e1074d1840fb2e516f44a2af16a92b3418 /tests/tst_TemperatureModel.qml | |
| parent | 647eefc8eb6201807418d62d07618bf87e212de6 (diff) | |
| download | unitmaster-6e444978a1c327c7cd98ded195478dc6906dc1b7.tar.gz unitmaster-6e444978a1c327c7cd98ded195478dc6906dc1b7.zip | |
add tests for other units too
Diffstat (limited to 'tests/tst_TemperatureModel.qml')
| -rw-r--r-- | tests/tst_TemperatureModel.qml | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/tst_TemperatureModel.qml b/tests/tst_TemperatureModel.qml new file mode 100644 index 0000000..301b095 --- /dev/null +++ b/tests/tst_TemperatureModel.qml @@ -0,0 +1,39 @@ +import QtQuick 2.0 +import QtTest 1.0 + +import "../harbour-unitmaster/qml/pages" + +TestCase { + name: "TemperatureModelTest" + + TemperatureModel { + id: model + } + + function test_to_data() { + return [ + { to: "celcius", value: 50, res: 50-273.15 }, + { to: "celcius", value: 0, res: -273.15 }, + { to: "fahrenheit", value: 100, res: 100*9/5-459.67 }, + { to: "rankine", value: 1, res: 1*9/5 } + ]; + } + + function test_to(data) { + var result = model.to(data.to, data.value); + compare(result, data.res); + } + + function test_from_data() { + return [ + { from: "celcius", value: 1, res: 1+273.15 }, + { from: "fahrenheit", value: 1, res: (1+459.67)*5/9 }, + { from: "rankine", value: 59, res: 59*5/9 } + ]; + } + + function test_from(data) { + var result = model.from(data.from, data.value); + compare(result, data.res); + } +} |
