assert: fix the string length check for printing the simple diff · nodejs/node@7af76ef · GitHub
Skip to content

Commit 7af76ef

Browse files
Giovanni Bucciaduh95
authored andcommitted
assert: fix the string length check for printing the simple diff
PR-URL: #55474 Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 6ab59c8 commit 7af76ef

3 files changed

Lines changed: 31 additions & 16 deletions

File tree

lib/internal/assert/assertion_error.js

Lines changed: 8 additions & 1 deletion

test/parallel/test-assert-deep.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,26 @@ test('Additional tests', () => {
846846
}
847847
);
848848

849+
assert.throws(
850+
() => assert.strictEqual('apple', 'pear'),
851+
{
852+
name: 'AssertionError',
853+
message: 'Expected values to be strictly equal:\n\n\'apple\' !== \'pear\'\n'
854+
}
855+
);
856+
857+
assert.throws(
858+
() => assert.strictEqual('ABABABABABAB', 'BABABABABABA'),
859+
{
860+
name: 'AssertionError',
861+
message: 'Expected values to be strictly equal:\n' +
862+
'+ actual - expected\n' +
863+
'\n' +
864+
"+ 'ABABABABABAB'\n" +
865+
"- 'BABABABABABA'\n"
866+
}
867+
);
868+
849869
assert.notDeepStrictEqual(new Date(), new Date(2000, 3, 14));
850870

851871
assert.throws(

test/parallel/test-assert.js

Lines changed: 3 additions & 15 deletions

0 commit comments

Comments
 (0)