-
Notifications
You must be signed in to change notification settings - Fork 0
/
ascii.test.js
116 lines (114 loc) · 1.78 KB
/
ascii.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
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
const ascii = require("./ascii");
const asciiTable = {
20: " ",
21: "!",
22: '"',
23: "#",
24: "$",
25: "%",
26: "&",
27: "'",
28: "(",
29: ")",
"2a": "*",
"2b": "+",
"2c": ",",
"2d": "-",
"2e": ".",
"2f": "/",
30: "0",
31: "1",
32: "2",
33: "3",
34: "4",
35: "5",
36: "6",
37: "7",
38: "8",
39: "9",
"3a": ":",
"3b": ";",
"3c": "<",
"3d": "=",
"3e": ">",
"3f": "?",
40: "@",
41: "A",
42: "B",
43: "C",
44: "D",
45: "E",
46: "F",
47: "G",
48: "H",
49: "I",
"4a": "J",
"4b": "K",
"4c": "L",
"4d": "M",
"4e": "N",
"4f": "O",
50: "P",
51: "Q",
52: "R",
53: "S",
54: "T",
55: "U",
56: "V",
57: "W",
58: "X",
59: "Y",
"5a": "Z",
"5b": "[",
"5c": "\\",
"5d": "]",
"5e": "^",
"5f": "_",
60: "`",
61: "a",
62: "b",
63: "c",
64: "d",
65: "e",
66: "f",
67: "g",
68: "h",
69: "i",
"6a": "j",
"6b": "k",
"6c": "l",
"6d": "m",
"6e": "n",
"6f": "o",
70: "p",
71: "q",
72: "r",
73: "s",
74: "t",
75: "u",
76: "v",
77: "w",
78: "x",
79: "y",
"7a": "z",
"7b": "{",
"7c": "|",
"7d": "}",
"7e": "~",
};
describe("Ascii helper file", () => {
describe("Encode all characters", () => {
it("can encode all characters", async () => {
const expectedString = Object.keys(asciiTable).join("");
const stringToEncode = Object.values(asciiTable).join("");
expect(ascii.encode(stringToEncode)).toEqual(expectedString);
});
});
describe("Decode all characters", () => {
it("can decode all characters", async () => {
const expectedString = Object.values(asciiTable).join("");
const stringToDecode = Object.keys(asciiTable).join("");
expect(ascii.decode(stringToDecode)).toEqual(expectedString);
});
});
});