forked from Shastel/brackets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
91 lines (70 loc) · 3.32 KB
/
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
const assert = require('assert');
Object.freeze(assert);
const check = require('./src/index.js');
const config1 = [['(', ')']];
const config2 = [['(', ')'], ['[', ']']];
const config3 = [['(', ')'], ['[', ']'], ['{', '}']];
const config4 = [['|', '|']];
const config5 = [['(', ')'], ['|', '|']];
const config6 = [['1', '2'], ['3', '4'], ['5', '6'], ['7', '7'], ['8', '8']];
const config7 = [['(', ')'], ['[', ']'], ['{', '}'], ['|', '|']];
it('should check if brackets sequence is correct 1', () => {
assert.equal(check('()', config1), true);
});
it('should check if brackets sequence is correct 2', () => {
assert.equal(check('((()))()', config1), true);
});
it('should check if brackets sequence is not correct 3', () => {
assert.equal(check('())(', config1), false);
});
it('should check if brackets sequence is correct 4', () => {
assert.equal(check('([{}])', config3), true);
});
it('should check if brackets sequence is not correct 5', () => {
assert.equal(check('[(])', config2), false);
});
it('should check if brackets sequence is correct 6', () => {
assert.equal(check('[]()', config2), true);
});
it('should check if brackets sequence is not correct 7', () => {
assert.equal(check('[]()(', config2), false);
});
it('should check if brackets sequence is correct 8', () => {
assert.equal(check('||', config4), true);
});
it('should check if brackets sequence is correct 9', () => {
assert.equal(check('|()|', config5), true);
});
it('should check if brackets sequence is not correct 10', () => {
assert.equal(check('|(|)', config5), false);
});
it('should check if brackets sequence is correct 11', () => {
assert.equal(check('|()|(||)||', config5), true);
});
it('should check if brackets sequence is correct 12', () => {
assert.equal(check('111115611111111222288888822225577877778775555666677777777776622222', config6), true);
});
it('should check if brackets sequence is not correct 13', () => {
assert.equal(check('5555512575557777777555566667888888667661133833448441111222233333444442266666', config6), false);
});
it('should check if brackets sequence is not correct 14', () => {
assert.equal(check('8888877878887777777888888887777777887887788788887887777777788888888887788888', config6), false);
});
it('should check if brackets sequence is correct 15', () => {
assert.equal(check('111115611111111156111111112222888888222255778777787755556666777777777766222221111222288888822225577877778775555666677777777776622222', config6), true);
});
it('should check if brackets sequence is not correct 16', () => {
assert.equal(check('[]][[]', config3), false);
});
it('should check if brackets sequence is not correct 17', () => {
assert.equal(check('[]][[]', config2), false);
});
it('should check if brackets sequence is not correct 18', () => {
assert.equal(check('([[[[(({{{}}}(([](((((((())))||||||))))[[{{|{{}}|}}[[[[]]]]{{{{{}}}}}]]))))]]]]))()', config7), false);
});
it('should check if brackets sequence is correct 19', () => {
assert.equal(check('([[[[(({{{}}}(([](((((((())))||||||))))[[{{|{{}}|}}[[[[]]]]{{{{{}}}}}]]))))]]]])(())', config7), true);
});
it('should check if brackets sequence is correct 20', () => {
assert.equal(check('([[[[(({{{}}}(([](((((((())))||||||))))[[{{|{{}}|}}[[[[]]]]{{{{{}}}}}]]))))]]]])((([[[[(({{{}}}(([](((((((())))||||||))))[[{{|{{}}|}}[[[[]]]]{{{{{}}}}}]]))))]]]])))', config7), true);
});