forked from AndyEveritt/GcodeParser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_split_params.py
More file actions
53 lines (32 loc) · 1.52 KB
/
test_split_params.py
File metadata and controls
53 lines (32 loc) · 1.52 KB
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
from gcodeparser.gcode_parser import (
GcodeLine,
GcodeParser,
get_lines,
element_type,
split_params,
)
from gcodeparser.commands import Commands
def test_split_int_params():
assert split_params(' P0 S1 X10') == {'P': 0, 'S': 1, 'X': 10}
def test_split_float_params():
assert split_params(' P0.1 S1.1345 X10.0') == {'P': 0.1, 'S': 1.1345, 'X': 10.0}
def test_split_sub1_params():
assert split_params(' P0.00001 S-0.00021 X.0001 Y-.003213') == {'P': 0.00001, 'S': -0.00021, 'X': 0.0001, 'Y': -0.003213}
def test_split_string_params():
assert split_params(' P"string"') == {'P': '"string"'}
def test_split_string_with_semicolon_params():
assert split_params(' P"string ; semicolon"') == {'P': '"string ; semicolon"'}
def test_split_neg_int_params():
assert split_params(' P-0 S-1 X-10') == {'P': 0, 'S': -1, 'X': -10}
def test_split_neg_float_params():
assert split_params(' P-0.1 S-1.1345 X-10.0') == {'P': -0.1, 'S': -1.1345, 'X': -10.0}
def test_split_ip_params():
assert split_params('P192.168.0.1 S1') == {'P': '192.168.0.1', 'S': 1}
def test_split_no_space_params():
assert split_params('P0.1S1.1345X10.0A"string"') == {'P': 0.1, 'S': 1.1345, 'X': 10.0, 'A': '"string"'}
def test_split_no_value_params():
assert split_params(' X') == {'X': True}
def test_split_multi_no_value_params():
assert split_params(' XYZ') == {'X': True, 'Y': True, 'Z': True}
def test_split_multi_no_value_spaced_params():
assert split_params(' X Y Z') == {'X': True, 'Y': True, 'Z': True}