-
Notifications
You must be signed in to change notification settings - Fork 0
/
08.test.js
85 lines (71 loc) · 2.79 KB
/
08.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
const { describeDay } = require('../test-utils')
describeDay(
2016,
8,
110,
'\n' +
'#### ## # # ### # # ## ### # # # ## \n' +
' # # # # # # # # # # # # # # # # \n' +
' # # #### # # ## # # # # # # # \n' +
' # # # # ### # # # ### # # # \n' +
'# # # # # # # # # # # # # # # # \n' +
'#### ## # # # # # # ## # #### # ## \n',
({ setRect, rotateColumn, rotateRow }) => {
test('rect 3x2 creates a small rectangle in the top-left corner', () => {
expect.assertions(1)
const screen = [
[false, false, false, false, false, false, false],
[false, false, false, false, false, false, false],
[false, false, false, false, false, false, false],
]
setRect(screen, 3, 2)
expect(screen).toStrictEqual([
[true, true, true, false, false, false, false],
[true, true, true, false, false, false, false],
[false, false, false, false, false, false, false],
])
})
test('rotate column x=1 by 1 rotates the second column down by one pixel', () => {
expect.assertions(1)
const screen = [
[true, true, true, false, false, false, false],
[true, true, true, false, false, false, false],
[false, false, false, false, false, false, false],
]
rotateColumn(screen, 1, 1)
expect(screen).toStrictEqual([
[true, false, true, false, false, false, false],
[true, true, true, false, false, false, false],
[false, true, false, false, false, false, false],
])
})
test('rotate row y=0 by 4 rotates the top row right by four pixels', () => {
expect.assertions(1)
const screen = [
[true, false, true, false, false, false, false],
[true, true, true, false, false, false, false],
[false, true, false, false, false, false, false],
]
rotateRow(screen, 0, 4)
expect(screen).toStrictEqual([
[false, false, false, false, true, false, true],
[true, true, true, false, false, false, false],
[false, true, false, false, false, false, false],
])
})
test('rotate column x=1 by 1 again rotates the second column down by one pixel, causing the bottom pixel to wrap back to the top', () => {
expect.assertions(1)
const screen = [
[false, false, false, false, true, false, true],
[true, true, true, false, false, false, false],
[false, true, false, false, false, false, false],
]
rotateColumn(screen, 1, 1)
expect(screen).toStrictEqual([
[false, true, false, false, true, false, true],
[true, false, true, false, false, false, false],
[false, true, false, false, false, false, false],
])
})
},
)