-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchallenge21.test.js
77 lines (68 loc) · 1.61 KB
/
challenge21.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
import { test, describe, expect, expectTypeOf } from 'vitest'
import { findBalancedSegment } from './challenge21'
describe('Binary message', () => {
test('Test 1', () => {
expectTypeOf(findBalancedSegment).returns.toEqualTypeOf([])
})
test('Test 2', () => {
const received = findBalancedSegment([1, 1, 0, 1, 1, 0, 1, 1])
const expected = [
2,
5
]
expect(received).toEqual(expected)
})
test('Test 3', () => {
const received = findBalancedSegment([1, 1, 0])
const expected = [
1,
2
]
expect(received).toEqual(expected)
})
test('Test 4', () => {
const received = findBalancedSegment([1, 1, 1])
const expected = []
expect(received).toEqual(expected)
})
test('Test 5', () => {
const received = findBalancedSegment([1, 0, 1])
const expected = [
0,
1
]
expect(received).toEqual(expected)
})
test('Test 6', () => {
const received = findBalancedSegment([1, 0, 1, 0])
const expected = [
0,
3
]
expect(received).toEqual(expected)
})
test('Test 7', () => {
const received = findBalancedSegment([1, 1, 0, 1, 0, 1])
const expected = [
1,
4
]
expect(received).toEqual(expected)
})
test('Test 8', () => {
const received = findBalancedSegment([1, 0, 0, 0, 1, 1, 1, 0, 0, 0])
const expected = [
0,
7
]
expect(received).toEqual(expected)
})
test('Test 6', () => {
const received = findBalancedSegment([0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1])
const expected = [
5,
10
]
expect(received).toEqual(expected)
})
})