Browse Source

test: replaced literals in errors with templates

PR-URL: https://github.com/nodejs/node/pull/15911
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
v6.x-staging
Paul Milham 7 years ago
committed by Myles Borins
parent
commit
44f3efc5e3
No known key found for this signature in database GPG Key ID: 933B01F40B5CA946
  1. 52
      test/parallel/test-buffer-indexof.js

52
test/parallel/test-buffer-indexof.js

@ -209,26 +209,26 @@ assert.strictEqual(
// Test single char pattern // Test single char pattern
assert.strictEqual(0, twoByteString.indexOf('\u039a', 0, 'ucs2')); assert.strictEqual(0, twoByteString.indexOf('\u039a', 0, 'ucs2'));
assert.strictEqual(2, twoByteString.indexOf('\u0391', 0, 'ucs2'), let index = twoByteString.indexOf('\u0391', 0, 'ucs2');
'Alpha'); assert.strictEqual(2, index, `Alpha - at index ${index}`);
assert.strictEqual(4, twoByteString.indexOf('\u03a3', 0, 'ucs2'), index = twoByteString.indexOf('\u03a3', 0, 'ucs2');
'First Sigma'); assert.strictEqual(4, index, `First Sigma - at index ${index}`);
assert.strictEqual(6, twoByteString.indexOf('\u03a3', 6, 'ucs2'), index = twoByteString.indexOf('\u03a3', 6, 'ucs2');
'Second Sigma'); assert.strictEqual(6, index, `Second Sigma - at index ${index}`);
assert.strictEqual(8, twoByteString.indexOf('\u0395', 0, 'ucs2'), index = twoByteString.indexOf('\u0395', 0, 'ucs2');
'Epsilon'); assert.strictEqual(8, index, `Epsilon - at index ${index}`);
assert.strictEqual(-1, twoByteString.indexOf('\u0392', 0, 'ucs2'), index = twoByteString.indexOf('\u0392', 0, 'ucs2');
'Not beta'); assert.strictEqual(-1, index, `Not beta - at index ${index}`);
// Test multi-char pattern // Test multi-char pattern
assert.strictEqual( index = twoByteString.indexOf('\u039a\u0391', 0, 'ucs2');
0, twoByteString.indexOf('\u039a\u0391', 0, 'ucs2'), 'Lambda Alpha'); assert.strictEqual(0, index, `Lambda Alpha - at index ${index}`);
assert.strictEqual( index = twoByteString.indexOf('\u0391\u03a3', 0, 'ucs2');
2, twoByteString.indexOf('\u0391\u03a3', 0, 'ucs2'), 'Alpha Sigma'); assert.strictEqual(2, index, `Alpha Sigma - at index ${index}`);
assert.strictEqual( index = twoByteString.indexOf('\u03a3\u03a3', 0, 'ucs2');
4, twoByteString.indexOf('\u03a3\u03a3', 0, 'ucs2'), 'Sigma Sigma'); assert.strictEqual(4, index, `Sigma Sigma - at index ${index}`);
assert.strictEqual( index = twoByteString.indexOf('\u03a3\u0395', 0, 'ucs2');
6, twoByteString.indexOf('\u03a3\u0395', 0, 'ucs2'), 'Sigma Epsilon'); assert.strictEqual(6, index, `Sigma Epsilon - at index ${index}`);
} }
const mixedByteStringUtf8 = Buffer.from('\u039a\u0391abc\u03a3\u03a3\u0395'); const mixedByteStringUtf8 = Buffer.from('\u039a\u0391abc\u03a3\u03a3\u0395');
@ -255,16 +255,18 @@ for (let i = 0; i < longBufferString.length - pattern.length; i += 7) {
assert.strictEqual((i + 15) & ~0xf, index, assert.strictEqual((i + 15) & ~0xf, index,
`Long ABACABA...-string at index ${i}`); `Long ABACABA...-string at index ${i}`);
} }
assert.strictEqual(510, longBufferString.indexOf('AJABACA'),
'Long AJABACA, First J'); let index = longBufferString.indexOf('AJABACA');
assert.strictEqual( assert.strictEqual(510, index, `Long AJABACA, First J - at index ${index}`);
1534, longBufferString.indexOf('AJABACA', 511), 'Long AJABACA, Second J'); index = longBufferString.indexOf('AJABACA', 511);
assert.strictEqual(1534, index, `Long AJABACA, Second J - at index ${index}`);
pattern = 'JABACABADABACABA'; pattern = 'JABACABADABACABA';
index = longBufferString.indexOf(pattern);
assert.strictEqual(511, index, `Long JABACABA..., First J - at index ${index}`);
index = longBufferString.indexOf(pattern, 512);
assert.strictEqual( assert.strictEqual(
511, longBufferString.indexOf(pattern), 'Long JABACABA..., First J'); 1535, index, `Long JABACABA..., Second J - at index ${index}`);
assert.strictEqual(
1535, longBufferString.indexOf(pattern, 512), 'Long JABACABA..., Second J');
// Search for a non-ASCII string in a pure ASCII string. // Search for a non-ASCII string in a pure ASCII string.
const asciiString = Buffer.from( const asciiString = Buffer.from(

Loading…
Cancel
Save