@@ -41,7 +41,25 @@ assert.strictEqual(d.length, 0);
41
41
assert . strictEqual ( b . offset , 0 ) ;
42
42
}
43
43
44
+ // Test creating a Buffer from a Uint8Array
45
+ {
46
+ const ui8 = new Uint8Array ( 4 ) . fill ( 42 ) ;
47
+ const e = Buffer . from ( ui8 ) ;
48
+ for ( const [ index , value ] of e . entries ( ) ) {
49
+ assert . strictEqual ( value , ui8 [ index ] ) ;
50
+ }
51
+ }
52
+ // Test creating a Buffer from a Uint8Array (old constructor)
53
+ {
54
+ const ui8 = new Uint8Array ( 4 ) . fill ( 42 ) ;
55
+ const e = Buffer ( ui8 ) ;
56
+ for ( const [ key , value ] of e . entries ( ) ) {
57
+ assert . strictEqual ( value , ui8 [ key ] ) ;
58
+ }
59
+ }
60
+
44
61
// Test creating a Buffer from a Uint32Array
62
+ // Note: it is implicitly interpreted as Array of integers modulo 256
45
63
{
46
64
const ui32 = new Uint32Array ( 4 ) . fill ( 42 ) ;
47
65
const e = Buffer . from ( ui32 ) ;
@@ -50,11 +68,12 @@ assert.strictEqual(d.length, 0);
50
68
}
51
69
}
52
70
// Test creating a Buffer from a Uint32Array (old constructor)
71
+ // Note: it is implicitly interpreted as Array of integers modulo 256
53
72
{
54
73
const ui32 = new Uint32Array ( 4 ) . fill ( 42 ) ;
55
74
const e = Buffer ( ui32 ) ;
56
75
for ( const [ key , value ] of e . entries ( ) ) {
57
- assert . deepStrictEqual ( value , ui32 [ key ] ) ;
76
+ assert . strictEqual ( value , ui32 [ key ] ) ;
58
77
}
59
78
}
60
79
0 commit comments