Skip to content

Commit 193cd97

Browse files
committed
✅ fix test coverage
1 parent 0fec8f4 commit 193cd97

File tree

43 files changed

+289
-209
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+289
-209
lines changed

Diff for: fixtures/test-util/oj-data.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function testOjCodes<T extends (...input: any[]) => any>(
3838
const { title, fetchData } = DATA_MAP[key]
3939

4040
// eslint-disable-next-line jest/valid-title
41-
test(title, async function () {
41+
it(title, async function () {
4242
const data = await fetchData()
4343
const solve: T = isPromise(solution) ? (await solution).default : solution
4444
for (const { input, answer } of data) expect(solve(...input)).toEqual(answer)

Diff for: fixtures/test-util/sort.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ export function addSortTest<T = unknown>(caseGroup: ISortTestCaseGroup<T>): void
6060
}
6161
})
6262

63-
test('run', async () => {
63+
it('run', async () => {
6464
runs.forEach(run => run())
6565
})
6666

67-
test('check', async () => {
67+
it('check', async () => {
6868
checks.forEach(check => check())
6969
})
7070
})

Diff for: jest.config.mjs

+34
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,28 @@ const coverageMap = {
3939
statements: 0,
4040
},
4141
},
42+
//
43+
'@algorithm.ts/bipartite-matching': {
44+
global: {
45+
functions: 87,
46+
lines: 95,
47+
statements: 95,
48+
},
49+
},
50+
'@algorithm.ts/calculator': {
51+
global: {
52+
branches: 97,
53+
lines: 98,
54+
statements: 98,
55+
},
56+
},
57+
'@algorithm.ts/findset': {
58+
global: {
59+
functions: 88,
60+
lines: 96,
61+
statements: 96,
62+
},
63+
},
4264
'@algorithm.ts/gomoku': {
4365
global: {
4466
branches: 92,
@@ -47,4 +69,16 @@ const coverageMap = {
4769
statements: 99,
4870
},
4971
},
72+
'@algorithm.ts/shuffle': {
73+
global: {
74+
branches: 88,
75+
},
76+
},
77+
'@algorithm.ts/sudoku': {
78+
global: {
79+
branches: 96,
80+
lines: 99,
81+
statements: 99,
82+
},
83+
},
5084
}

Diff for: packages/_internal/__test__/constant.spec.ts

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import {
2+
BIGINT_ONE,
3+
BIGINT_ZERO,
4+
CODEPOINT_DIGIT_0,
5+
CODEPOINT_DIGIT_9,
6+
CODEPOINT_LOWER_A,
7+
CODEPOINT_LOWER_Z,
8+
CODEPOINT_UPPER_A,
9+
CODEPOINT_UPPER_Z,
10+
} from '../src'
11+
12+
describe('constant', () => {
13+
it('zero', () => {
14+
expect(BIGINT_ZERO).toEqual(0n)
15+
})
16+
17+
it('one', () => {
18+
expect(BIGINT_ONE).toEqual(1n)
19+
})
20+
21+
describe('codepoint', () => {
22+
it('0', () => {
23+
expect(CODEPOINT_DIGIT_0).toEqual(48)
24+
})
25+
26+
it('9', () => {
27+
expect(CODEPOINT_DIGIT_9).toEqual(57)
28+
})
29+
30+
it('A', () => {
31+
expect(CODEPOINT_UPPER_A).toEqual(65)
32+
})
33+
34+
it('Z', () => {
35+
expect(CODEPOINT_UPPER_Z).toEqual(90)
36+
})
37+
38+
it('a', () => {
39+
expect(CODEPOINT_LOWER_A).toEqual(97)
40+
})
41+
42+
it('z', () => {
43+
expect(CODEPOINT_LOWER_Z).toEqual(122)
44+
})
45+
})
46+
})

Diff for: packages/base64/__test__/base64.spec.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ describe('basic', () => {
2121
},
2222
]
2323

24-
test('encode', function () {
24+
it('encode', function () {
2525
for (const { plaintext, ciphertext } of kases) {
2626
expect(encode(getBytes(plaintext))).toEqual(ciphertext)
2727
}
2828
})
2929

30-
test('decode', function () {
30+
it('decode', function () {
3131
for (const { plaintext, ciphertext } of kases) {
3232
expect(decode(ciphertext)).toEqual(getBytes(plaintext))
3333
}
3434
})
3535

36-
test('validate', function () {
36+
it('validate', function () {
3737
expect(validate('a')).toBe(false)
3838
expect(validate('aa')).toBe(false)
3939
expect(validate('aaa')).toBe(false)
@@ -67,24 +67,24 @@ describe('custom', () => {
6767
},
6868
]
6969

70-
test('encode', function () {
70+
it('encode', function () {
7171
for (const { plaintext, ciphertext } of kases) {
7272
expect(base64.encode(getBytes(plaintext))).toEqual(ciphertext)
7373
}
7474
})
7575

76-
test('decode', function () {
76+
it('decode', function () {
7777
for (const { plaintext, ciphertext } of kases) {
7878
expect(base64.decode(ciphertext)).toEqual(getBytes(plaintext))
7979
}
8080
})
8181
})
8282

8383
describe('misc', () => {
84-
test('%4 == 0', () => testWithBytes(1000))
85-
test('%4 == 1', () => testWithBytes(1001))
86-
test('%4 == 2', () => testWithBytes(1002))
87-
test('%4 == 3', () => testWithBytes(1003))
84+
it('%4 == 0', () => testWithBytes(1000))
85+
it('%4 == 1', () => testWithBytes(1001))
86+
it('%4 == 2', () => testWithBytes(1002))
87+
it('%4 == 3', () => testWithBytes(1003))
8888

8989
function testWithBytes(size: number): void {
9090
const data = new Uint8Array(size)

Diff for: packages/bellman-ford/__test__/bellman-ford.spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { BellmanFord, bellmanFord, bellmanFordBigint } from '../src'
66

77
describe('basic', function () {
88
describe('bellmanFord', function () {
9-
test('no negative cycle', function () {
9+
it('no negative cycle', function () {
1010
const graph: IBellmanFordGraph<number> = {
1111
N: 4,
1212
source: 0,
@@ -26,7 +26,7 @@ describe('basic', function () {
2626
expect(result.dist.slice(0, graph.N)).toEqual([0, 2, 4, 4])
2727
})
2828

29-
test('negative cycle', function () {
29+
it('negative cycle', function () {
3030
const graph: IBellmanFordGraph<number> = {
3131
N: 4,
3232
source: 0,
@@ -43,7 +43,7 @@ describe('basic', function () {
4343
})
4444

4545
describe('bellmanFordBigint', function () {
46-
test('no negative cycle', function () {
46+
it('no negative cycle', function () {
4747
const graph: IBellmanFordGraph<bigint> = {
4848
N: 4,
4949
source: 0,
@@ -63,7 +63,7 @@ describe('basic', function () {
6363
expect(result.dist.slice(0, graph.N)).toEqual([0n, 2n, 4n, 4n])
6464
})
6565

66-
test('negative cycle', function () {
66+
it('negative cycle', function () {
6767
const graph: IBellmanFordGraph<bigint> = {
6868
N: 4,
6969
source: 0,
@@ -81,7 +81,7 @@ describe('basic', function () {
8181
})
8282

8383
describe('shortest path', function () {
84-
test('without negative cycle', function () {
84+
it('without negative cycle', function () {
8585
enum Nodes {
8686
A = 0,
8787
B = 1,
@@ -127,7 +127,7 @@ describe('shortest path', function () {
127127
])
128128
})
129129

130-
test('with negative cycle', function () {
130+
it('with negative cycle', function () {
131131
enum Nodes {
132132
A = 0,
133133
B = 1,

Diff for: packages/binary-index-tree/__test__/IntervalUpdateSingleQuery.spec.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { IntervalUpdateSingleQuery } from '../src'
44
describe('IntervalUpdateSingleQuery', function () {
55
describe('basic', function () {
66
const MAX_N = 1000
7-
test('number', function () {
7+
it('number', function () {
88
const bit = new IntervalUpdateSingleQuery<number>({
99
operator: {
1010
ZERO: 0,
@@ -43,7 +43,7 @@ describe('IntervalUpdateSingleQuery', function () {
4343
bit.query(1)
4444
})
4545

46-
test('bigint', function () {
46+
it('bigint', function () {
4747
const bit = new IntervalUpdateSingleQuery<bigint>({
4848
operator: {
4949
ZERO: 0n,
@@ -86,7 +86,7 @@ describe('IntervalUpdateSingleQuery', function () {
8686
describe('modulo', function () {
8787
const MAX_N = 1000
8888

89-
test('number', function () {
89+
it('number', function () {
9090
const MOD = 1000 + 17
9191
const bit = new IntervalUpdateSingleQuery<number>({
9292
operator: {
@@ -129,7 +129,7 @@ describe('IntervalUpdateSingleQuery', function () {
129129
bit.query(1)
130130
})
131131

132-
test('bigint', function () {
132+
it('bigint', function () {
133133
const MOD = BigInt(1000 + 17)
134134
const bit = new IntervalUpdateSingleQuery<bigint>({
135135
operator: {
@@ -174,7 +174,7 @@ describe('IntervalUpdateSingleQuery', function () {
174174
bit.query(-1)
175175
})
176176
})
177-
test('edge', function () {
177+
it('edge', function () {
178178
const bit = new IntervalUpdateSingleQuery<number>({
179179
operator: {
180180
ZERO: 0,

Diff for: packages/binary-index-tree/__test__/SingleUpdateIntervalQuery.spec.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ describe('SingleUpdateIntervalQuery', function () {
55
describe('basic', function () {
66
const MAX_N = 1000
77

8-
test('number', function () {
8+
it('number', function () {
99
const bit = new SingleUpdateIntervalQuery<number>({
1010
operator: {
1111
ZERO: 0,
@@ -40,7 +40,7 @@ describe('SingleUpdateIntervalQuery', function () {
4040
bit.query(-1)
4141
})
4242

43-
test('bigint', function () {
43+
it('bigint', function () {
4444
const bit = new SingleUpdateIntervalQuery<bigint>({
4545
operator: {
4646
ZERO: 0n,
@@ -79,7 +79,7 @@ describe('SingleUpdateIntervalQuery', function () {
7979
describe('modulo', function () {
8080
const MAX_N = 1000
8181

82-
test('number', function () {
82+
it('number', function () {
8383
const MOD = 1000 + 17
8484
const bit = new SingleUpdateIntervalQuery<number>({
8585
operator: {
@@ -117,7 +117,7 @@ describe('SingleUpdateIntervalQuery', function () {
117117
bit.query(-1)
118118
})
119119

120-
test('bigint', function () {
120+
it('bigint', function () {
121121
const MOD = BigInt(1000 + 17)
122122
const bit = new SingleUpdateIntervalQuery<bigint>({
123123
operator: {
@@ -156,7 +156,7 @@ describe('SingleUpdateIntervalQuery', function () {
156156
})
157157
})
158158

159-
test('edge', function () {
159+
it('edge', function () {
160160
const bit = new SingleUpdateIntervalQuery<number>({
161161
operator: {
162162
ZERO: 0,

Diff for: packages/binary-search/__test__/binary-search.spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe('binarySearch', function () {
77
mid =>
88
mid === x ? 0 : mid < x ? -1 : 1
99

10-
test('basic', function () {
10+
it('basic', function () {
1111
const lft = -(2 ** 30)
1212
const rht = 2 ** 30
1313

@@ -16,7 +16,7 @@ describe('binarySearch', function () {
1616
}
1717
})
1818

19-
test('edge', function () {
19+
it('edge', function () {
2020
const lft = -(2 ** 30)
2121
const rht = 2 ** 30
2222
expect(binarySearch(lft, lft, hitFor(lft))).toEqual(null)
@@ -38,7 +38,7 @@ describe('binarySearchBigint', () => {
3838
mid =>
3939
mid === x ? 0 : mid < x ? -1 : 1
4040

41-
test('basic', function () {
41+
it('basic', function () {
4242
const lft = -5000000000000n
4343
const rht = 500000000000000000000000000n
4444

@@ -47,7 +47,7 @@ describe('binarySearchBigint', () => {
4747
}
4848
})
4949

50-
test('edge', function () {
50+
it('edge', function () {
5151
const lft = -5000000000000n
5252
const rht = 500000000000000000000000000n
5353

Diff for: packages/binary-search/__test__/lower-bound.spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe('lowerBound', function () {
77
mid =>
88
mid === x ? 0 : mid < x ? -1 : 1
99

10-
test('basic', function () {
10+
it('basic', function () {
1111
const lft = -(2 ** 30)
1212
const rht = 2 ** 30
1313

@@ -16,7 +16,7 @@ describe('lowerBound', function () {
1616
}
1717
})
1818

19-
test('edge', function () {
19+
it('edge', function () {
2020
const lft = -(2 ** 30)
2121
const rht = 2 ** 30
2222

@@ -39,7 +39,7 @@ describe('lowerBoundBigint', () => {
3939
mid =>
4040
mid === x ? 0 : mid < x ? -1 : 1
4141

42-
test('basic', function () {
42+
it('basic', function () {
4343
const lft = -5000000000000n
4444
const rht = 500000000000000000000000000n
4545

@@ -48,7 +48,7 @@ describe('lowerBoundBigint', () => {
4848
}
4949
})
5050

51-
test('edge', function () {
51+
it('edge', function () {
5252
const lft = -5000000000000n
5353
const rht = 500000000000000000000000000n
5454

0 commit comments

Comments
 (0)