-
Notifications
You must be signed in to change notification settings - Fork 0
/
unit_test.py
119 lines (114 loc) · 3.26 KB
/
unit_test.py
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/python
import console80v2
singleton = console80v2.singleIntValue()
print "=== Singleton Time ==="
print ""
print singleton
print ""
print "Set a max number of items in history"
singleton.setMaxHistoryLength(4)
print singleton
print ""
print "Add 0 through 7 to history"
for i in range(1,8):
singleton.updateValue(i)
print singleton
print "Increase the history length"
singleton.setMaxHistoryLength(5)
print "Add 1 through 19 to history"
for i in range(1,20):
singleton.updateValue(i)
print singleton
print ""
print "History statistics"
print "Avg: {}".format(singleton.getHistoryAvg())
print "Max: {}".format(singleton.getHistoryMax())
print "Min: {}".format(singleton.getHistoryMin())
print "Last 1: {}".format(singleton.getHistoryLast())
print "Last 3: {}".format(singleton.getHistoryLast(3))
print ""
print "Get current Value"
print "Current: {}".format(singleton.getValue())
print "Scaled: {}".format(singleton.getScaledValue())
print ""
print "Add values outside the range"
singleton.updateValue(101)
print "Get the value back {}".format(singleton.getValue())
print "Get a scaled value back {}".format(singleton.getScaledValue())
print "Am I clipping {}".format(singleton.isClipped())
print ""
singleton.updateValue(-1)
print "Get the value back {}".format(singleton.getValue())
print "Get a scaled value back {}".format(singleton.getScaledValue())
print "Am I clipping {}".format(singleton.isClipped())
print ""
singleton.updateValue(5)
print singleton
print "Get the value back {}".format(singleton.getValue())
print "Am I clipping {}".format(singleton.isClipped())
print ""
print "Set the range 1 - 10"
singleton.setRange((0,10))
print singleton
print ""
print "Sweep to 10 and back"
for i in range(22):
singleton.sweepValue()
print singleton
print ""
print ""
coord = console80v2.singleCoordValue()
print "=== Co-Ordinates Time ==="
print ""
print coord
print ""
print "Set a max number of items in history to 4"
coord.setMaxHistoryLength(4)
print coord
print ""
print "Add 0 through 7 to history"
for i in range(1,8):
coord.updateValue((i**2,i**2))
print coord
print ""
print "Set a max number of items in history to 5"
coord.setMaxHistoryLength(5)
print coord
print ""
print "Add 1 through 19 to history"
for i in range(4,8):
coord.updateValue((i**2,i**2))
print coord
print ""
print "History statistics"
print "Avg: {}".format(coord.getHistoryAvg())
print "Max: {}".format(coord.getHistoryMax())
print "Min: {}".format(coord.getHistoryMin())
print "Last 1: {}".format(coord.getHistoryLast())
print "Last 3: {}".format(coord.getHistoryLast(3))
print ""
print "Get current Value"
print "Current: {}".format(coord.getValue())
print ""
print "Add values outside the range"
coord.updateValue((101,101))
print "Get the value back {}".format(coord.getValue())
print "Am I clipping {}".format(coord.isClipped())
print ""
coord.updateValue((-1,-1))
print "Get the value back {}".format(coord.getValue())
print "Am I clipping {}".format(coord.isClipped())
print ""
coord.updateValue((0,0))
print "Get the value back {}".format(coord.getValue())
print "Am I clipping {}".format(coord.isClipped())
print ""
print "Set the range -5,-5 - 5,5"
coord.setRange(((-5 , -5) , (5 , 5)))
print coord
print ""
print "Sweep to 5 and back to -5"
for i in range(22):
coord.sweepValue()
print coord
print ""