aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorOskari Timperi <oskari.timperi@iki.fi>2013-12-08 14:46:45 +0200
committerOskari Timperi <oskari.timperi@iki.fi>2013-12-08 14:46:45 +0200
commit6e444978a1c327c7cd98ded195478dc6906dc1b7 (patch)
treecd80a2e1074d1840fb2e516f44a2af16a92b3418 /tests
parent647eefc8eb6201807418d62d07618bf87e212de6 (diff)
downloadunitmaster-6e444978a1c327c7cd98ded195478dc6906dc1b7.tar.gz
unitmaster-6e444978a1c327c7cd98ded195478dc6906dc1b7.zip
add tests for other units too
Diffstat (limited to 'tests')
-rw-r--r--tests/tests.pro6
-rw-r--r--tests/tst_AngleModel.qml40
-rw-r--r--tests/tst_LengthModel.qml52
-rw-r--r--tests/tst_PressureModel.qml46
-rw-r--r--tests/tst_TemperatureModel.qml39
5 files changed, 182 insertions, 1 deletions
diff --git a/tests/tests.pro b/tests/tests.pro
index 8bf47f1..dc06374 100644
--- a/tests/tests.pro
+++ b/tests/tests.pro
@@ -25,4 +25,8 @@ SOURCES += main.cpp
INSTALLS += target qml extra
OTHER_FILES += \
- tst_MassModel.qml
+ tst_MassModel.qml \
+ tst_AngleModel.qml \
+ tst_LengthModel.qml \
+ tst_PressureModel.qml \
+ tst_TemperatureModel.qml
diff --git a/tests/tst_AngleModel.qml b/tests/tst_AngleModel.qml
new file mode 100644
index 0000000..9074906
--- /dev/null
+++ b/tests/tst_AngleModel.qml
@@ -0,0 +1,40 @@
+import QtQuick 2.0
+import QtTest 1.0
+
+import "../harbour-unitmaster/qml/pages"
+
+TestCase {
+ name: "AngleModelTest"
+
+ AngleModel {
+ id: model
+ }
+
+ function test_to_data() {
+ return [
+ { to: 'degree', value: 1, res: 180.0/Math.PI },
+ { to: 'gon', value: 1, res: 200.0/Math.PI },
+ { to: 'arcminute', value: 1, res: 10800/Math.PI },
+ { to: 'arcsecond', value: 1, res: 648000/Math.PI }
+ ];
+ }
+
+ function test_to(data) {
+ var result = model.to(data.to, data.value);
+ compare(result, data.res);
+ }
+
+ function test_from_data() {
+ return [
+ { from: 'degree', value: 1, res: Math.PI/180.0 },
+ { from: 'gon', value: 1, res: Math.PI/200.0 },
+ { from: 'arcminute', value: 1, res: Math.PI/10800 },
+ { from: 'arcsecond', value: 1, res: Math.PI/648000 }
+ ];
+ }
+
+ function test_from(data) {
+ var result = model.from(data.from, data.value);
+ compare(result, data.res);
+ }
+}
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);
+ }
+}
diff --git a/tests/tst_PressureModel.qml b/tests/tst_PressureModel.qml
new file mode 100644
index 0000000..e25f89f
--- /dev/null
+++ b/tests/tst_PressureModel.qml
@@ -0,0 +1,46 @@
+import QtQuick 2.0
+import QtTest 1.0
+
+import "../harbour-unitmaster/qml/pages"
+
+TestCase {
+ name: "PressureModelTest"
+
+ PressureModel {
+ id: model
+ }
+
+ function test_to_data() {
+ return [
+ { to: "kilopascal", value: 1234, res: 1.234 },
+ { to: "bar", value: 1, res: 1e-5 },
+ { to: "millibar", value: 1, res: 0.01 },
+ { to: "pounds per square inch", value: 1, res: 1.450377e-4 },
+ { to: "technical atmosphere", value: 1, res: 1.0197e-5 },
+ { to: "standard atmosphere", value: 1, res: 9.8692e-6 },
+ { to: "torr", value: 1, res: 7.5006e-3 }
+ ];
+ }
+
+ function test_to(data) {
+ var result = model.to(data.to, data.value);
+ compare(result, data.res);
+ }
+
+ function test_from_data() {
+ return [
+ { from: "kilopascal", value: 1, res: 1000 },
+ { from: "bar", value: 1, res: 1e5 },
+ { from: "millibar", value: 1, res: 100 },
+ { from: "pounds per square inch", value: 1, res: 6.8948e3 },
+ { from: "technical atmosphere", value: 1, res: 0.980665e5 },
+ { from: "standard atmosphere", value: 1, res: 1.01325e5 },
+ { from: "torr", value: 1, res: 133.3224 }
+ ];
+ }
+
+ function test_from(data) {
+ var result = model.from(data.from, data.value);
+ compare(result, data.res);
+ }
+}
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);
+ }
+}