summaryrefslogtreecommitdiffstats
path: root/lab_control/test/measurement_unittest.py
blob: 07716a3ae42bbcfb0ed0228dcf318e99b337d325 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
import pytest

from lab_control.measurement import *

@pytest.fixture
def uut():
    return Measurement()

def test_linearRangeAscending():
    first = 100.0
    last = 200.0
    steps = 11

    expectedRange = [
        100.0, 110.0, 120.0, 130.0,
        140.0, 150.0, 160.0, 170.0,
        180.0, 190.0, 200.0
    ]

    actualRange = getLinearRange(first, last, steps)
    assert actualRange == expectedRange

def test_linearRangeDescending():
    first = 200.0
    last = 180.0
    steps = 3

    expectedRange = [
        200.0, 190.0, 180.0
    ]

    actualRange = getLinearRange(first, last, steps)
    assert actualRange == expectedRange

def test_linearRangeTwoSteps():
    first = 20.0
    last = -20.0
    steps = 2

    expectedRange = [
        20.0, -20.0
    ]

    actualRange = getLinearRange(first, last, steps)
    assert actualRange == expectedRange

def test_linearRangeOneStep():
    first = 20.0
    last = -20.0
    steps = 1

    with pytest.raises(AssertionError):
        actualRange = getLinearRange(first, last, steps)