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_LengthModel.qml | |
| parent | 647eefc8eb6201807418d62d07618bf87e212de6 (diff) | |
| download | unitmaster-6e444978a1c327c7cd98ded195478dc6906dc1b7.tar.gz unitmaster-6e444978a1c327c7cd98ded195478dc6906dc1b7.zip | |
add tests for other units too
Diffstat (limited to 'tests/tst_LengthModel.qml')
| -rw-r--r-- | tests/tst_LengthModel.qml | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/tst_LengthModel.qml b/tests/tst_LengthModel.qml new file mode 100644 index 0000000..9f44e9e --- /dev/null +++ b/tests/tst_LengthModel.qml @@ -0,0 +1,52 @@ +import QtQuick 2.0 +import QtTest 1.0 + +import "../harbour-unitmaster/qml/pages" + +TestCase { + name: "LengthModelTest" + + LengthModel { + id: model + } + + function test_to_data() { + return [ + { to: 'kilometer', value: 50, res: 0.05 }, + { to: 'decimeter', value: 1, res: 10 }, + { to: 'centimeter', value: 1.256, res: 125.6 }, + { to: 'millimeter', value: 0.1, res: 100 }, + { to: 'thou', value: 1, res: 1/(25.4e-6) }, + { to: 'inch', value: 1, res: 1/0.0254 }, + { to: 'foot', value: 1, res: 1/0.3048 }, + { to: 'yard', value: 1, res: 1/0.9144 }, + { to: 'mile', value: 1, res: 1/1609.344 }, + { to: 'nautical mile', value: 1, res: 1/1852 } + ]; + } + + function test_to(data) { + var result = model.to(data.to, data.value); + compare(result, data.res); + } + + function test_from_data() { + return [ + { from: 'kilometer', value: 1, res: 1000 }, + { from: 'decimeter', value: 1, res: 0.1 }, + { from: 'centimeter', value: 1, res: 0.01 }, + { from: 'millimeter', value: 1, res: 0.001 }, + { from: 'thou', value: 1, res: 25.4e-6 }, + { from: 'inch', value: 1, res: 0.0254 }, + { from: 'foot', value: 1, res: 0.3048 }, + { from: 'yard', value: 1, res: 0.9144 }, + { from: 'mile', value: 1, res: 1609.344 }, + { from: 'nautical mile', value: 1, res: 1852 } + ]; + } + + function test_from(data) { + var result = model.from(data.from, data.value); + compare(result, data.res); + } +} |
