Skip to content

Commit 314ee79

Browse files
universal-hex: Add tests for Intel Hex files with invalid EoF records not at the end of the file.
1 parent 6510f80 commit 314ee79

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

src/__tests__/universal-hex.spec.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,23 +1127,47 @@ describe('Test createUniversalHex()', () => {
11271127
':1000600069E80000D59A0100D9930100678E01006C\n' + ':00000001FF\n'
11281128
);
11291129

1130-
const failFirst = () => {
1130+
const failFirstBlocks = () => {
1131+
const result = uh.createUniversalHex(
1132+
[
1133+
{ hex: normalHexEof10, boardId: 0x9900 },
1134+
{ hex: normalHex, boardId: 0x9903 },
1135+
],
1136+
true
1137+
);
1138+
};
1139+
const failFirstSections = () => {
11311140
const result = uh.createUniversalHex([
11321141
{ hex: normalHexEof10, boardId: 0x9900 },
11331142
{ hex: normalHex, boardId: 0x9903 },
11341143
]);
11351144
};
1136-
const failSecond = () => {
1145+
const failSecondBlocks = () => {
1146+
const result = uh.createUniversalHex(
1147+
[
1148+
{ hex: normalHex, boardId: 0x9900 },
1149+
{ hex: normalHexEof12, boardId: 0x9903 },
1150+
],
1151+
true
1152+
);
1153+
};
1154+
const failSecondSections = () => {
11371155
const result = uh.createUniversalHex([
11381156
{ hex: normalHex, boardId: 0x9900 },
11391157
{ hex: normalHexEof12, boardId: 0x9903 },
11401158
]);
11411159
};
11421160

1143-
expect(failFirst).toThrow(
1161+
expect(failFirstBlocks).toThrow(
1162+
'EoF record found at line 10 of 14 in Board ID 39168'
1163+
);
1164+
expect(failFirstSections).toThrow(
11441165
'EoF record found at line 10 of 14 in Board ID 39168'
11451166
);
1146-
expect(failSecond).toThrow(
1167+
expect(failSecondBlocks).toThrow(
1168+
'EoF record found at line 12 of 14 in Board ID 39171'
1169+
);
1170+
expect(failSecondSections).toThrow(
11471171
'EoF record found at line 12 of 14 in Board ID 39171'
11481172
);
11491173
});

0 commit comments

Comments
 (0)