Skip to content

Commit 663a35b

Browse files
authored
test: expand stripControlCharacters edge-case coverage (#554)
- Empty string and printable-only strings pass through unchanged. - Boundary controls NUL (0x00), US (0x1F), and DEL (0x7F). - Multiple control characters stripped in one string. Addresses review feedback on regex /[\x00-\x1F\x7F]/g coverage from #553.
1 parent d3e9c20 commit 663a35b

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

src/renderer/lib/stripControlCharacters.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,30 @@ import { describe, expect, it } from 'vitest';
33
import { stripControlCharacters } from './stripControlCharacters';
44

55
describe('stripControlCharacters', () => {
6+
it('returns empty string unchanged', () => {
7+
expect(stripControlCharacters('')).toBe('');
8+
});
9+
10+
it('returns strings with no control characters unchanged', () => {
11+
expect(stripControlCharacters('hello world')).toBe('hello world');
12+
expect(stripControlCharacters('printable: ABC 123 !@#')).toBe('printable: ABC 123 !@#');
13+
});
14+
615
it('removes ASCII control characters and keeps printable text', () => {
716
expect(stripControlCharacters('hello\x07world')).toBe('helloworld');
817
expect(stripControlCharacters('line\x1fbreak')).toBe('linebreak');
918
});
19+
20+
it('removes boundary control characters (NUL and US)', () => {
21+
expect(stripControlCharacters('\x00start')).toBe('start');
22+
expect(stripControlCharacters('end\x1f')).toBe('end');
23+
});
24+
25+
it('removes DEL (0x7F)', () => {
26+
expect(stripControlCharacters('del\x7fchar')).toBe('delchar');
27+
});
28+
29+
it('removes multiple control characters in one string', () => {
30+
expect(stripControlCharacters('\x00a\x1fb\x7fc')).toBe('abc');
31+
});
1032
});

0 commit comments

Comments
 (0)