aboutsummaryrefslogtreecommitdiff
path: root/tests/tst_MassModel.qml
blob: 3a87132e2257c4bca8b7b3fa1fec5163db749ef7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import QtQuick 2.0
import QtTest 1.0

import "../harbour-unitmaster/qml/pages"

TestCase {
    name: "MassModelTest"

    MassModel {
        id: model
    }

    function test_to_data() {
        return [
                    { to: 'pound', value: 1, res: 2.2046226 },
                    { to: 'ounce', value: 1, res: 35.273961 },
                    { to: 'tonne', value: 1000, res: 1 },
                    { to: 'gram', value: 1, res: 1000 }
        ];
    }

    function test_to(data) {
        var result = model.to(data.to, data.value);
        compare(result, data.res);
    }

    function test_from_data() {
        return [
                    { from: 'pound', value: 1, res: 0.4536 },
                    { from: 'ounce', value: 1, res: 0.02835 },
                    { from: 'tonne', value: 1, res: 1000 },
                    { from: 'gram', value: 1, res: 0.001 }
        ];
    }

    function test_from(data) {
        var result = model.from(data.from, data.value);
        compare(result, data.res);
    }
}