FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaScript/Sorts/test/CombSort.test.js at master · TheAlgorithms/JavaScript · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
TheAlgorithms
/
JavaScript
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
5.8k
Star
34.2k
Code
Issues
21
Pull requests
192
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaScript
/
Sorts
/
test
/
CombSort.test.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
79 lines (64 loc) · 2.82 KB
Breadcrumbs
JavaScript
/
Sorts
/
test
/
CombSort.test.js
Copy path
File metadata and controls
79 lines (64 loc) · 2.82 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import
{
combSort
}
from
'../CombSort'
describe
(
'combSort function'
,
(
)
=>
{
it
(
'should correctly sort an input list that is sorted backwards'
,
(
)
=>
{
const
array
=
[
5
,
4
,
3
,
2
,
1
]
expect
(
combSort
(
array
)
)
.
toEqual
(
[
1
,
2
,
3
,
4
,
5
]
)
}
)
it
(
'should correctly sort an input list that is unsorted'
,
(
)
=>
{
const
array
=
[
15
,
24
,
3
,
2224
,
1
]
expect
(
combSort
(
array
)
)
.
toEqual
(
[
1
,
3
,
15
,
24
,
2224
]
)
}
)
describe
(
'Variations of input array lengths'
,
(
)
=>
{
it
(
'should return an empty list with the input list is an empty list'
,
(
)
=>
{
expect
(
combSort
(
[
]
)
)
.
toEqual
(
[
]
)
}
)
it
(
'should correctly sort an input list of length 1'
,
(
)
=>
{
expect
(
combSort
(
[
100
]
)
)
.
toEqual
(
[
100
]
)
}
)
it
(
'should correctly sort an input list of an odd length'
,
(
)
=>
{
expect
(
combSort
(
[
101
,
-
10
,
321
]
)
)
.
toEqual
(
[
-
10
,
101
,
321
]
)
}
)
it
(
'should correctly sort an input list of an even length'
,
(
)
=>
{
expect
(
combSort
(
[
40
,
42
,
56
,
45
,
12
,
3
]
)
)
.
toEqual
(
[
3
,
12
,
40
,
42
,
45
,
56
]
)
}
)
}
)
describe
(
'Variations of input array elements'
,
(
)
=>
{
it
(
'should correctly sort an input list that contains only positive numbers'
,
(
)
=>
{
expect
(
combSort
(
[
50
,
33
,
11
,
2
]
)
)
.
toEqual
(
[
2
,
11
,
33
,
50
]
)
}
)
it
(
'should correctly sort an input list that contains only negative numbers'
,
(
)
=>
{
expect
(
combSort
(
[
-
1
,
-
21
,
-
2
,
-
35
]
)
)
.
toEqual
(
[
-
35
,
-
21
,
-
2
,
-
1
]
)
}
)
it
(
'should correctly sort an input list that contains only a mix of positive and negative numbers'
,
(
)
=>
{
expect
(
combSort
(
[
-
40
,
42
,
56
,
-
45
,
12
,
-
3
]
)
)
.
toEqual
(
[
-
45
,
-
40
,
-
3
,
12
,
42
,
56
]
)
}
)
it
(
'should correctly sort an input list that contains only whole numbers'
,
(
)
=>
{
expect
(
combSort
(
[
11
,
3
,
12
,
4
,
-
15
]
)
)
.
toEqual
(
[
-
15
,
3
,
4
,
11
,
12
]
)
}
)
it
(
'should correctly sort an input list that contains only decimal numbers'
,
(
)
=>
{
expect
(
combSort
(
[
1.0
,
1.42
,
2.56
,
33.45
,
13.12
,
2.3
]
)
)
.
toEqual
(
[
1.0
,
1.42
,
2.3
,
2.56
,
13.12
,
33.45
]
)
}
)
it
(
'should correctly sort an input list that contains only a mix of whole and decimal'
,
(
)
=>
{
expect
(
combSort
(
[
32.4
,
12.42
,
56
,
45
,
12
,
3
]
)
)
.
toEqual
(
[
3
,
12
,
12.42
,
32.4
,
45
,
56
]
)
}
)
it
(
'should correctly sort an input list that contains only fractional numbers'
,
(
)
=>
{
expect
(
combSort
(
[
0.98
,
0.4259
,
0.56
,
-
0.456
,
-
0.12
,
0.322
]
)
)
.
toEqual
(
[
-
0.456
,
-
0.12
,
0.322
,
0.4259
,
0.56
,
0.98
]
)
}
)
it
(
'should correctly sort an input list that contains only a mix of whole, decimal, and fractional'
,
(
)
=>
{
expect
(
combSort
(
[
-
40
,
-
0.222
,
5.6
,
-
4.5
,
12
,
0.333
]
)
)
.
toEqual
(
[
-
40
,
-
4.5
,
-
0.222
,
0.333
,
5.6
,
12
]
)
}
)
it
(
'should correctly sort an input list that contains duplicates'
,
(
)
=>
{
expect
(
combSort
(
[
4
,
3
,
4
,
2
,
1
,
2
]
)
)
.
toEqual
(
[
1
,
2
,
2
,
3
,
4
,
4
]
)
}
)
}
)
}
)
Back
|
FazBrowse Home
|
New Git URL