FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
node/test/parallel/test-buffer-compare-offset.js at main · fetchapi/node · GitHub
fetchapi
/
node
Public
forked from
nodejs/node
Notifications
You must be signed in to change notification settings
Fork
1
Star
0
Code
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
node
/
test
/
parallel
/
test-buffer-compare-offset.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
94 lines (73 loc) · 2.69 KB
Breadcrumbs
node
/
test
/
parallel
/
test-buffer-compare-offset.js
Copy path
File metadata and controls
94 lines (73 loc) · 2.69 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
'use strict'
;
require
(
'../common'
)
;
const
assert
=
require
(
'assert'
)
;
const
a
=
Buffer
.
from
(
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
0
]
)
;
const
b
=
Buffer
.
from
(
[
5
,
6
,
7
,
8
,
9
,
0
,
1
,
2
,
3
,
4
]
)
;
assert
.
strictEqual
(
a
.
compare
(
b
)
,
-
1
)
;
// Equivalent to a.compare(b).
assert
.
strictEqual
(
a
.
compare
(
b
,
0
)
,
-
1
)
;
assert
.
throws
(
(
)
=>
a
.
compare
(
b
,
'0'
)
,
{
code
:
'ERR_INVALID_ARG_TYPE'
}
)
;
assert
.
strictEqual
(
a
.
compare
(
b
,
undefined
)
,
-
1
)
;
// Equivalent to a.compare(b).
assert
.
strictEqual
(
a
.
compare
(
b
,
0
,
undefined
,
0
)
,
-
1
)
;
// Zero-length target, return 1
assert
.
strictEqual
(
a
.
compare
(
b
,
0
,
0
,
0
)
,
1
)
;
assert
.
throws
(
(
)
=>
a
.
compare
(
b
,
0
,
'0'
,
'0'
)
,
{
code
:
'ERR_INVALID_ARG_TYPE'
}
)
;
// Equivalent to Buffer.compare(a, b.slice(6, 10))
assert
.
strictEqual
(
a
.
compare
(
b
,
6
,
10
)
,
1
)
;
// Zero-length source, return -1
assert
.
strictEqual
(
a
.
compare
(
b
,
6
,
10
,
0
,
0
)
,
-
1
)
;
// Zero-length source and target, return 0
assert
.
strictEqual
(
a
.
compare
(
b
,
0
,
0
,
0
,
0
)
,
0
)
;
assert
.
strictEqual
(
a
.
compare
(
b
,
1
,
1
,
2
,
2
)
,
0
)
;
// Equivalent to Buffer.compare(a.slice(4), b.slice(0, 5))
assert
.
strictEqual
(
a
.
compare
(
b
,
0
,
5
,
4
)
,
1
)
;
// Equivalent to Buffer.compare(a.slice(1), b.slice(5))
assert
.
strictEqual
(
a
.
compare
(
b
,
5
,
undefined
,
1
)
,
1
)
;
// Equivalent to Buffer.compare(a.slice(2), b.slice(2, 4))
assert
.
strictEqual
(
a
.
compare
(
b
,
2
,
4
,
2
)
,
-
1
)
;
// Equivalent to Buffer.compare(a.slice(4), b.slice(0, 7))
assert
.
strictEqual
(
a
.
compare
(
b
,
0
,
7
,
4
)
,
-
1
)
;
// Equivalent to Buffer.compare(a.slice(4, 6), b.slice(0, 7));
assert
.
strictEqual
(
a
.
compare
(
b
,
0
,
7
,
4
,
6
)
,
-
1
)
;
// Null is ambiguous.
assert
.
throws
(
(
)
=>
a
.
compare
(
b
,
0
,
null
)
,
{
code
:
'ERR_INVALID_ARG_TYPE'
}
)
;
// Values do not get coerced.
assert
.
throws
(
(
)
=>
a
.
compare
(
b
,
0
,
{
valueOf
:
(
)
=>
5
}
)
,
{
code
:
'ERR_INVALID_ARG_TYPE'
}
)
;
// Infinity should not be coerced.
assert
.
throws
(
(
)
=>
a
.
compare
(
b
,
Infinity
,
-
Infinity
)
,
{
code
:
'ERR_OUT_OF_RANGE'
}
)
;
// Zero length target because default for targetEnd <= targetSource
assert
.
strictEqual
(
a
.
compare
(
b
,
0xff
)
,
1
)
;
assert
.
throws
(
(
)
=>
a
.
compare
(
b
,
'0xff'
)
,
{
code
:
'ERR_INVALID_ARG_TYPE'
}
)
;
assert
.
throws
(
(
)
=>
a
.
compare
(
b
,
0
,
'0xff'
)
,
{
code
:
'ERR_INVALID_ARG_TYPE'
}
)
;
const
oor
=
{
code
:
'ERR_OUT_OF_RANGE'
}
;
assert
.
throws
(
(
)
=>
a
.
compare
(
b
,
0
,
100
,
0
)
,
oor
)
;
assert
.
throws
(
(
)
=>
a
.
compare
(
b
,
0
,
1
,
0
,
100
)
,
oor
)
;
assert
.
throws
(
(
)
=>
a
.
compare
(
b
,
-
1
)
,
oor
)
;
assert
.
throws
(
(
)
=>
a
.
compare
(
b
,
0
,
Infinity
)
,
oor
)
;
assert
.
throws
(
(
)
=>
a
.
compare
(
b
,
0
,
1
,
-
1
)
,
oor
)
;
assert
.
throws
(
(
)
=>
a
.
compare
(
b
,
-
Infinity
,
Infinity
)
,
oor
)
;
assert
.
throws
(
(
)
=>
a
.
compare
(
)
,
{
code
:
'ERR_INVALID_ARG_TYPE'
,
name
:
'TypeError'
,
message
:
'The "target" argument must be an instance of '
+
'Buffer or Uint8Array. Received undefined'
}
)
;
Back
|
FazBrowse Home
|
New Git URL