GeezerVison is showing github.com — test: improve internal/buffer.js test coverage · nodejs/node@17954c2
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-buffer-readint.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -169,7 +169,7 @@ const assert = require('assert'); | 169 | 169 | }); | 170 | 170 |
| 171 | 171 | // Test 1 to 6 bytes. | 172 | | - for (let i = 1; i < 6; i++) { | | 172 | + for (let i = 1; i <= 6; i++) { | 173 | 173 | ['readIntBE', 'readIntLE'].forEach((fn) => { | 174 | 174 | ['', '0', null, {}, [], () => {}, true, false].forEach((o) => { | 175 | 175 | assert.throws( | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-buffer-readuint.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -130,7 +130,7 @@ const assert = require('assert'); | 130 | 130 | }); | 131 | 131 |
| 132 | 132 | // Test 1 to 6 bytes. | 133 | | - for (let i = 1; i < 6; i++) { | | 133 | + for (let i = 1; i <= 6; i++) { | 134 | 134 | ['readUIntBE', 'readUIntLE'].forEach((fn) => { | 135 | 135 | ['', '0', null, {}, [], () => {}, true, false].forEach((o) => { | 136 | 136 | assert.throws( | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-buffer-writeint.js +15Lines changed: 15 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -162,6 +162,21 @@ const errorOutOfBounds = common.expectsError({ | 162 | 162 | }); | 163 | 163 | } | 164 | 164 |
| | 165 | +// Test 48 bit | | 166 | +{ | | 167 | + const value = 0x1234567890ab; | | 168 | + const buffer = Buffer.allocUnsafe(6); | | 169 | + buffer.writeIntBE(value, 0, 6); | | 170 | + assert.ok(buffer.equals(new Uint8Array([ | | 171 | + 0x12, 0x34, 0x56, 0x78, 0x90, 0xab | | 172 | + ]))); | | 173 | + | | 174 | + buffer.writeIntLE(value, 0, 6); | | 175 | + assert.ok(buffer.equals(new Uint8Array([ | | 176 | + 0xab, 0x90, 0x78, 0x56, 0x34, 0x12 | | 177 | + ]))); | | 178 | +} | | 179 | + | 165 | 180 | // Test Int | 166 | 181 | { | 167 | 182 | const data = Buffer.alloc(8); | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-buffer-writeuint.js +11Lines changed: 11 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -110,6 +110,17 @@ const assert = require('assert'); | 110 | 110 | assert.ok(data.equals(new Uint8Array([0x6d, 0x6d, 0x6d, 0x0a, 0xf9, 0xe7]))); | 111 | 111 | } | 112 | 112 |
| | 113 | +// Test 48 bit | | 114 | +{ | | 115 | + const value = 0x1234567890ab; | | 116 | + const data = Buffer.allocUnsafe(6); | | 117 | + data.writeUIntBE(value, 0, 6); | | 118 | + assert.ok(data.equals(new Uint8Array([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]))); | | 119 | + | | 120 | + data.writeUIntLE(value, 0, 6); | | 121 | + assert.ok(data.equals(new Uint8Array([0xab, 0x90, 0x78, 0x56, 0x34, 0x12]))); | | 122 | +} | | 123 | + | 113 | 124 | // Test UInt | 114 | 125 | { | 115 | 126 | const data = Buffer.alloc(8); | |
|