binutils64 0.1.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +65 -0
- package/LICENSE +21 -0
- package/README.md +48 -12
- package/binutils.d.ts +87 -0
- package/binutils.js +37 -16
- package/package.json +54 -17
- package/.claude/agents/binutils-reviewer.md +0 -58
- package/.claude/settings.local.json +0 -21
- package/.claude/skills/add-binary-type/SKILL.md +0 -93
- package/.claude/skills/test-binutils/SKILL.md +0 -91
- package/.github/workflows/test.yml +0 -22
- package/CLAUDE.md +0 -54
- package/test/edge-cases.test.js +0 -76
- package/test/reader.test.js +0 -106
- package/test/readme-examples.test.js +0 -33
- package/test/roundtrip.test.js +0 -120
- package/test/writer.test.js +0 -115
package/test/writer.test.js
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
var test = require('node:test');
|
|
2
|
-
var assert = require('node:assert/strict');
|
|
3
|
-
var binutils = require('../binutils.js');
|
|
4
|
-
var BinaryWriter = binutils.BinaryWriter;
|
|
5
|
-
|
|
6
|
-
function bytes(writer) {
|
|
7
|
-
return Array.from(writer.ByteBuffer);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
test('BinaryWriter: constructor defaults', function() {
|
|
11
|
-
var w = new BinaryWriter();
|
|
12
|
-
assert.equal(w.Endianness, 'big');
|
|
13
|
-
assert.equal(w.Encoding, 'ascii');
|
|
14
|
-
assert.equal(w.Length, 0);
|
|
15
|
-
assert.equal(w.ByteBuffer.length, 0);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test('BinaryWriter: WriteUInt8', function() {
|
|
19
|
-
var w = new BinaryWriter();
|
|
20
|
-
w.WriteUInt8(200);
|
|
21
|
-
assert.deepEqual(bytes(w), [200]);
|
|
22
|
-
assert.equal(w.Length, 1);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
test('BinaryWriter: WriteInt8 (signed)', function() {
|
|
26
|
-
var w = new BinaryWriter();
|
|
27
|
-
w.WriteInt8(-1);
|
|
28
|
-
assert.deepEqual(bytes(w), [0xFF]);
|
|
29
|
-
assert.equal(w.Length, 1);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('BinaryWriter: WriteUInt16 honors endianness', function() {
|
|
33
|
-
var big = new BinaryWriter('big');
|
|
34
|
-
big.WriteUInt16(0x1234);
|
|
35
|
-
assert.deepEqual(bytes(big), [0x12, 0x34]);
|
|
36
|
-
assert.equal(big.Length, 2);
|
|
37
|
-
|
|
38
|
-
var little = new BinaryWriter('little');
|
|
39
|
-
little.WriteUInt16(0x1234);
|
|
40
|
-
assert.deepEqual(bytes(little), [0x34, 0x12]);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('BinaryWriter: WriteUInt32 honors endianness', function() {
|
|
44
|
-
var big = new BinaryWriter('big');
|
|
45
|
-
big.WriteUInt32(0x12345678);
|
|
46
|
-
assert.deepEqual(bytes(big), [0x12, 0x34, 0x56, 0x78]);
|
|
47
|
-
assert.equal(big.Length, 4);
|
|
48
|
-
|
|
49
|
-
var little = new BinaryWriter('little');
|
|
50
|
-
little.WriteUInt32(0x12345678);
|
|
51
|
-
assert.deepEqual(bytes(little), [0x78, 0x56, 0x34, 0x12]);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test('BinaryWriter: WriteInt16 / WriteInt32 (signed)', function() {
|
|
55
|
-
var w16 = new BinaryWriter('big');
|
|
56
|
-
w16.WriteInt16(-2);
|
|
57
|
-
assert.deepEqual(bytes(w16), [0xFF, 0xFE]);
|
|
58
|
-
|
|
59
|
-
var w32 = new BinaryWriter('little');
|
|
60
|
-
w32.WriteInt32(-1);
|
|
61
|
-
assert.deepEqual(bytes(w32), [0xFF, 0xFF, 0xFF, 0xFF]);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
test('BinaryWriter: WriteFloat', function() {
|
|
65
|
-
var big = new BinaryWriter('big');
|
|
66
|
-
big.WriteFloat(1.5);
|
|
67
|
-
assert.deepEqual(bytes(big), [0x3F, 0xC0, 0x00, 0x00]);
|
|
68
|
-
assert.equal(big.Length, 4);
|
|
69
|
-
|
|
70
|
-
var little = new BinaryWriter('little');
|
|
71
|
-
little.WriteFloat(1.5);
|
|
72
|
-
assert.deepEqual(bytes(little), [0x00, 0x00, 0xC0, 0x3F]);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
test('BinaryWriter: WriteDouble', function() {
|
|
76
|
-
var w = new BinaryWriter('big');
|
|
77
|
-
w.WriteDouble(1.5);
|
|
78
|
-
assert.deepEqual(bytes(w), [0x3F, 0xF8, 0, 0, 0, 0, 0, 0]);
|
|
79
|
-
assert.equal(w.Length, 8);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
test('BinaryWriter: WriteBytes accepts an array', function() {
|
|
83
|
-
var w = new BinaryWriter();
|
|
84
|
-
w.WriteBytes([1, 2, 3]);
|
|
85
|
-
assert.deepEqual(bytes(w), [1, 2, 3]);
|
|
86
|
-
assert.equal(w.Length, 3);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
test('BinaryWriter: WriteBytes accepts a Buffer', function() {
|
|
90
|
-
var w = new BinaryWriter();
|
|
91
|
-
w.WriteBytes(Buffer.from([9, 8, 7]));
|
|
92
|
-
assert.deepEqual(bytes(w), [9, 8, 7]);
|
|
93
|
-
assert.equal(w.Length, 3);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
test('BinaryWriter: WriteBytes accepts a string (per-char codes)', function() {
|
|
97
|
-
var w = new BinaryWriter();
|
|
98
|
-
w.WriteBytes('ABC');
|
|
99
|
-
assert.deepEqual(bytes(w), [65, 66, 67]);
|
|
100
|
-
assert.equal(w.Length, 3);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
test('BinaryWriter: WriteBytes rejects non-Buffer/non-Array input', function() {
|
|
104
|
-
assert.throws(function() { new BinaryWriter().WriteBytes(4); }, /Invalid Buffer object/);
|
|
105
|
-
assert.throws(function() { new BinaryWriter().WriteBytes({}); }, /Invalid Buffer object/);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
test('BinaryWriter: multiple writes accumulate and track Length', function() {
|
|
109
|
-
var w = new BinaryWriter('big');
|
|
110
|
-
w.WriteUInt8(1);
|
|
111
|
-
w.WriteUInt16(0x0203);
|
|
112
|
-
w.WriteUInt32(0x04050607);
|
|
113
|
-
assert.deepEqual(bytes(w), [1, 2, 3, 4, 5, 6, 7]);
|
|
114
|
-
assert.equal(w.Length, 7);
|
|
115
|
-
});
|