-
Notifications
You must be signed in to change notification settings - Fork 0
/
translator.test.js
83 lines (74 loc) · 1.99 KB
/
translator.test.js
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
const translator = require("./translator");
test("translate 0 to internal 0 using {offset:0,numerator:2}", () => {
expect(
translator.toInternal(0, {
offset: 0,
numerator: 1
})
).toBe(0);
});
test("translate 2 to internal 1 using {offset:0,numerator:2} ", () => {
expect(
translator.toInternal(2, {
offset: 0,
numerator: 2
})
).toBe(1);
});
test("translate 2 to internal 1 using {offset:1,numerator:1} ", () => {
expect(
translator.toInternal(2, {
offset: 1,
numerator: 1
})
).toBe(1);
});
test("translate 'two' to internal 1 using {offset:1,numerator:1,texttable:[{lowerLimit:2, upperLimit:2, text:'zwei'}]} ", () => {
expect(
translator.toInternal("two", {
offset: 1,
numerator: 1,
textTable: [{ lowerLimit: 2, upperLimit: 2, text: "two" }]
})
).toBe(1);
});
test("translate hex '00FF' to physical 'two' using {offset:1,numerator:1,texttable:[{hexDump:'00FF', text:'two'}]} ", () => {
expect(
translator.toPhysical(BigInt(0xff), {
textTable: [{ hexDump: "00FF", text: "two" }]
})
).toBe("two");
});
test("translate 0 to physical 0 using {offset:0,numerator:2} ", () => {
expect(
translator.toPhysical(0, {
offset: 0,
numerator: 1
})
).toBe(0);
});
test("translate 1 to physical 2 using {offset:0,numerator:2} ", () => {
expect(
translator.toPhysical(1, {
offset: 0,
numerator: 2
})
).toBe(2);
});
test("translate 1 to physical 2 using {offset:1,numerator:1} ", () => {
expect(
translator.toPhysical(1, {
offset: 1,
numerator: 1
})
).toBe(2);
});
test("translate 1 to physical 'two' using {offset:1,numerator:1,texttable:[{lowerLimit:2, upperLimit:2, text:'zwei'}]} ", () => {
expect(
translator.toPhysical(1, {
offset: 1,
numerator: 1,
textTable: [{ lowerLimit: 2, upperLimit: 2, text: "two" }]
})
).toBe("two");
});