Skip to content

Commit b0926d7

Browse files
committed
fix import
1 parent e1fe2cc commit b0926d7

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

packages/tsurlfilter/test/utils/string-utils.test.ts

+13-12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
hasUnquotedSubstring,
55
fastHash,
66
replaceAll,
7+
getUtf8EncodedLength,
78
} from '../../src/utils/string-utils';
89

910
describe('splitByDelimiterWithEscapeCharacter', () => {
@@ -135,55 +136,55 @@ describe('fastHash', () => {
135136
});
136137
});
137138

138-
describe('stringUtils.getUtf8EncodedLength', () => {
139+
describe('getUtf8EncodedLength', () => {
139140
it('should return 0 for an empty string', () => {
140-
expect(stringUtils.getUtf8EncodedLength('')).toBe(0);
141+
expect(getUtf8EncodedLength('')).toBe(0);
141142
});
142143

143144
it('should return 1 for a single ASCII character', () => {
144145
// ASCII character
145-
expect(stringUtils.getUtf8EncodedLength('A')).toBe(1);
146+
expect(getUtf8EncodedLength('A')).toBe(1);
146147
});
147148

148149
it('should return the correct byte length for a string with multiple ASCII characters', () => {
149150
// "Hello" consists of 5 ASCII characters
150-
expect(stringUtils.getUtf8EncodedLength('Hello')).toBe(5);
151+
expect(getUtf8EncodedLength('Hello')).toBe(5);
151152
});
152153

153154
it('should return 2 for a 2-byte UTF-8 character (e.g., é)', () => {
154155
// 'é' is a 2-byte character in UTF-8
155-
expect(stringUtils.getUtf8EncodedLength('é')).toBe(2);
156+
expect(getUtf8EncodedLength('é')).toBe(2);
156157
});
157158

158159
it('should return 3 for a 3-byte UTF-8 character (e.g., 中)', () => {
159160
// '中' is a 3-byte character in UTF-8
160-
expect(stringUtils.getUtf8EncodedLength('中')).toBe(3);
161+
expect(getUtf8EncodedLength('中')).toBe(3);
161162
});
162163

163164
it('should return 4 for a 4-byte UTF-8 character (e.g., smiley emoji)', () => {
164165
// '😄' is a 4-byte character in UTF-8 (surrogate pair)
165-
expect(stringUtils.getUtf8EncodedLength('😄')).toBe(4);
166+
expect(getUtf8EncodedLength('😄')).toBe(4);
166167
});
167168

168169
it('should handle mixed strings with ASCII and multi-byte UTF-8 characters', () => {
169170
// "Hello " = 6 bytes, 'é' = 2 bytes
170-
expect(stringUtils.getUtf8EncodedLength('Hello é')).toBe(8);
171+
expect(getUtf8EncodedLength('Hello é')).toBe(8);
171172
});
172173

173174
it('should handle surrogate pairs correctly', () => {
174175
const complexEmoji = '👨‍👩‍👧‍👦'; // Family emoji
175-
expect(stringUtils.getUtf8EncodedLength(complexEmoji)).toBe(25); // Surrogate pairs and ZWJ
176+
expect(getUtf8EncodedLength(complexEmoji)).toBe(25); // Surrogate pairs and ZWJ
176177
});
177178

178179
it('should return correct byte length for characters in different byte ranges', () => {
179180
// 'A' = 1 byte, 'é' = 2 bytes, '中' = 3 bytes, '😄' = 4 bytes
180-
expect(stringUtils.getUtf8EncodedLength('Aé中😄')).toBe(10);
181+
expect(getUtf8EncodedLength('Aé中😄')).toBe(10);
181182
});
182183

183184
it('should correctly handle special characters like newline, tabs, etc.', () => {
184185
// Newline is a single byte in UTF-8
185-
expect(stringUtils.getUtf8EncodedLength('\n')).toBe(1);
186+
expect(getUtf8EncodedLength('\n')).toBe(1);
186187
// Tab is a single byte in UTF-8
187-
expect(stringUtils.getUtf8EncodedLength('\t')).toBe(1);
188+
expect(getUtf8EncodedLength('\t')).toBe(1);
188189
});
189190
});

0 commit comments

Comments
 (0)